gnark-crypto
gnark-crypto copied to clipboard
Feat: Add BLS signature scheme
Needs #312 and #313 to be merged
Any ETA on when you guys think this is going to get merged?
Any ETA on when you guys think this is going to get merged?
The scheme is pretty much implemented (just need to be rebased on top of last master). The PR review was delayed because of other high priority work (Linea related) popped up. I hope we can go back to this soon!
Been playing with this library a bit. I'm curious, why is there no aggregation function on PublicKey and Signature structs? The only way I could find to do aggregation was this clumsy way:
func main() {
msg := []byte("testing BLS aggregation")
sk1, _ := bls.GenerateKey(rand.Reader)
pk1 := sk1.PublicKey
sig1Bytes, _ := sk1.Sign(msg, nil)
sig1 := new(bls.Signature)
_, err := sig1.SetBytes(sig1Bytes)
if err != nil {
panic(err)
}
sk2, _ := bls.GenerateKey(rand.Reader)
pk2 := sk2.PublicKey
sig2Bytes, _ := sk2.Sign(msg, nil)
sig2 := new(bls.Signature)
_, err = sig2.SetBytes(sig2Bytes)
if err != nil {
panic(err)
}
aggPk := new(bls.PublicKey)
aggPk.A.Set(pk1.A.Add(&pk1.A, &pk2.A))
aggSig := new(bls.Signature)
aggSig.S.Set(sig1.S.Add(&sig1.S, &sig2.S))
ok, err := aggPk.Verify(aggSig.Bytes(), msg, nil)
if err != nil {
panic(err)
}
fmt.Println("Signature verified?", ok)
}
Am I doing something wrong?