From bafc755bb2a855b807933d57d66820961a1dc433 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Mon, 15 Apr 2024 12:00:49 -0500 Subject: [PATCH] Switch to signatures on G2, Resolves #96 Signed-off-by: Jakub Sztandera --- blssig/aggregation.go | 7 +++---- blssig/signer.go | 6 +++--- blssig/suite_test.go | 4 ++-- blssig/verifier.go | 8 +++++--- sim/sim.go | 4 ++-- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/blssig/aggregation.go b/blssig/aggregation.go index a2e60a09..09b390c1 100644 --- a/blssig/aggregation.go +++ b/blssig/aggregation.go @@ -7,7 +7,6 @@ import ( "github.com/drand/kyber" "github.com/drand/kyber/sign" - "github.com/drand/kyber/sign/bdn" "golang.org/x/xerrors" ) @@ -22,7 +21,7 @@ func (v Verifier) Aggregate(pubkeys []gpbft.PubKey, signatures [][]byte) ([]byte return nil, xerrors.Errorf("converting public keys to mask: %w", err) } - aggSigPoint, err := bdn.AggregateSignatures(v.suite, signatures, mask) + aggSigPoint, err := v.scheme.AggregateSignatures(signatures, mask) if err != nil { return nil, xerrors.Errorf("computing aggregate signature: %w", err) } @@ -40,12 +39,12 @@ func (v Verifier) VerifyAggregate(msg []byte, signature []byte, pubkeys []gpbft. return xerrors.Errorf("converting public keys to mask: %w", err) } - aggPubKey, err := bdn.AggregatePublicKeys(v.suite, mask) + aggPubKey, err := v.scheme.AggregatePublicKeys(mask) if err != nil { return xerrors.Errorf("aggregating public keys: %w", err) } - return bdn.Verify(v.suite, aggPubKey, msg, signature) + return v.scheme.Verify(aggPubKey, msg, signature) } func (v Verifier) pubkeysToMask(pubkeys []gpbft.PubKey) (*sign.Mask, error) { diff --git a/blssig/signer.go b/blssig/signer.go index ac6b0a6d..0d5fedce 100644 --- a/blssig/signer.go +++ b/blssig/signer.go @@ -21,12 +21,12 @@ type Signer struct { keys map[string]kyber.Scalar } -func SignerWithKeyOnG2() *Signer { +func SignerWithKeyOnG1() *Signer { suite := bls12381.NewBLS12381Suite() return &Signer{ suite: suite, - scheme: bls.NewSchemeOnG1(suite), - keyGroup: suite.G2(), + scheme: bls.NewSchemeOnG2(suite), + keyGroup: suite.G1(), keys: make(map[string]kyber.Scalar), } } diff --git a/blssig/suite_test.go b/blssig/suite_test.go index 049c8928..cf3bbb2d 100644 --- a/blssig/suite_test.go +++ b/blssig/suite_test.go @@ -9,6 +9,6 @@ import ( func TestBLSSigning(t *testing.T) { test.NewSigningSuite( - blssig.SignerWithKeyOnG2(), - blssig.VerifierWithKeyOnG2()).Run(t) + blssig.SignerWithKeyOnG1(), + blssig.VerifierWithKeyOnG1()).Run(t) } diff --git a/blssig/verifier.go b/blssig/verifier.go index 46b58fc5..f274e3ac 100644 --- a/blssig/verifier.go +++ b/blssig/verifier.go @@ -11,14 +11,16 @@ import ( type Verifier struct { suite pairing.Suite + scheme *bdn.Scheme keyGroup kyber.Group } -func VerifierWithKeyOnG2() Verifier { +func VerifierWithKeyOnG1() Verifier { suite := bls12381.NewBLS12381Suite() return Verifier{ suite: suite, - keyGroup: suite.G2(), + scheme: bdn.NewSchemeOnG2(suite), + keyGroup: suite.G1(), } } @@ -32,5 +34,5 @@ func (v Verifier) Verify(pubKey gpbft.PubKey, msg, sig []byte) error { return xerrors.Errorf("the public key is a null point") } - return bdn.Verify(v.suite, pubKeyPoint, msg, sig) + return v.scheme.Verify(pubKeyPoint, msg, sig) } diff --git a/sim/sim.go b/sim/sim.go index 5ad4a813..4422e2d0 100644 --- a/sim/sim.go +++ b/sim/sim.go @@ -48,8 +48,8 @@ func FakeSigningBacked() *SigningBacked { func BLSSigningBacked() *SigningBacked { return &SigningBacked{ - Signer: blssig.SignerWithKeyOnG2(), - Verifier: blssig.VerifierWithKeyOnG2(), + Signer: blssig.SignerWithKeyOnG1(), + Verifier: blssig.VerifierWithKeyOnG1(), } }