From b128d446f2b97a6e6987c9e3503f3f1d7f9a6685 Mon Sep 17 00:00:00 2001 From: Nishant Das Date: Wed, 6 Oct 2021 10:48:56 +0800 Subject: [PATCH] Bring Eth2FastAggregateVerify Inline With the Spec (#9742) * fix * tie it closer to the spec --- crypto/bls/blst/signature.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/crypto/bls/blst/signature.go b/crypto/bls/blst/signature.go index fc5f0e073..336b04b55 100644 --- a/crypto/bls/blst/signature.go +++ b/crypto/bls/blst/signature.go @@ -118,7 +118,11 @@ func (s *Signature) FastAggregateVerify(pubKeys []common.PublicKey, msg [32]byte if len(pubKeys) == 0 { return false } - return s.innerFastAggregateVerify(pubKeys, msg) + rawKeys := make([]*blstPublicKey, len(pubKeys)) + for i := 0; i < len(pubKeys); i++ { + rawKeys[i] = pubKeys[i].(*PublicKey).p + } + return s.s.FastAggregateVerify(true, rawKeys, msg[:], dst) } // Eth2FastAggregateVerify implements a wrapper on top of bls's FastAggregateVerify. It accepts G2_POINT_AT_INFINITY signature @@ -139,15 +143,7 @@ func (s *Signature) Eth2FastAggregateVerify(pubKeys []common.PublicKey, msg [32] if len(pubKeys) == 0 && bytes.Equal(s.Marshal(), common.InfiniteSignature[:]) { return true } - return s.innerFastAggregateVerify(pubKeys, msg) -} - -func (s *Signature) innerFastAggregateVerify(pubKeys []common.PublicKey, msg [32]byte) bool { - rawKeys := make([]*blstPublicKey, len(pubKeys)) - for i := 0; i < len(pubKeys); i++ { - rawKeys[i] = pubKeys[i].(*PublicKey).p - } - return s.s.FastAggregateVerify(true, rawKeys, msg[:], dst) + return s.FastAggregateVerify(pubKeys, msg) } // NewAggregateSignature creates a blank aggregate signature.