Bring Eth2FastAggregateVerify Inline With the Spec (#9742)

* fix

* tie it closer to the spec
This commit is contained in:
Nishant Das 2021-10-06 10:48:56 +08:00 committed by GitHub
parent 9aa50352b6
commit b128d446f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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.