gnark-crypto icon indicating copy to clipboard operation
gnark-crypto copied to clipboard

Feat: Add BLS signature scheme

Open yelhousni opened this issue 2 years ago • 5 comments

yelhousni avatar Jan 26 '23 12:01 yelhousni

Needs #312 and #313 to be merged

yelhousni avatar Jan 26 '23 12:01 yelhousni

sandritis2 avatar Jun 18 '23 14:06 sandritis2

Any ETA on when you guys think this is going to get merged?

samlaf avatar Aug 25 '23 21:08 samlaf

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!

yelhousni avatar Sep 06 '23 17:09 yelhousni

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?

samlaf avatar Sep 16 '23 21:09 samlaf