Open mratsim opened 2 years ago
We unfortunately need one of those default init RFC in Nim https://github.com/nim-lang/RFCs/issues/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).
https://github.com/status-im/nim-blscurve/pull/120#discussion_r681980253