Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Miracl] Default init to infinity point #122

Open
mratsim opened this issue Sep 14, 2021 · 1 comment
Open

[Miracl] Default init to infinity point #122

mratsim opened this issue Sep 14, 2021 · 1 comment

Comments

@mratsim
Copy link
Contributor

mratsim commented Sep 14, 2021

#120 (comment)

@mratsim
Copy link
Contributor Author

mratsim commented Dec 22, 2021

We unfortunately need one of those default init RFC in Nim nim-lang/RFCs#252.

The portable patterns are

# Low-level
var P {.noInit.}: ECP2_BLS12381
P.setInf
# High-level
var p {.noInit.}: Aggregate
p.init(firstElem)

If we need really empty aggregate within BLScurve (instead of just handling the special case at serialization/deserialization) we could add the following function with caveats for Miracl backend:

  func initEmpty*(agg: var Aggregate) {.inline.} =
    ## Initialize an empty aggregate signature or public key.
    ## This is a delicate procedure to use.
    ## 
    ## ⚠ Empty public-key or signatures created by this procedure
    ##   are infinity points to allow further aggregation.
    ##   - Some protocols might serialize an empty aggregate differently
    ##     from an infinity point, for example Ethereum:
    ##       Empty aggregate:         0x0000...0000
    ##       Infinity point ("zero"): 0xc000...0000
    ##   - Some protocols, like BLS signatures, might not allow raw empty aggregates of certain kind.
    agg.point.inf()

BLST has no public API to create infinity points (though default init is by chance the infinity point).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant