mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
Remove Skip BLS Verification Feature (#11233)
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
@@ -20,7 +20,6 @@ go_library(
|
||||
],
|
||||
deps = [
|
||||
"//cache/lru:go_default_library",
|
||||
"//config/features:go_default_library",
|
||||
"//config/fieldparams:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//crypto/bls/common:go_default_library",
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
lruwrpr "github.com/prysmaticlabs/prysm/v3/cache/lru"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/features"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v3/crypto/bls/common"
|
||||
@@ -23,9 +22,6 @@ type PublicKey struct {
|
||||
|
||||
// PublicKeyFromBytes creates a BLS public key from a BigEndian byte slice.
|
||||
func PublicKeyFromBytes(pubKey []byte) (common.PublicKey, error) {
|
||||
if features.Get().SkipBLSVerify {
|
||||
return &PublicKey{}, nil
|
||||
}
|
||||
if len(pubKey) != params.BeaconConfig().BLSPubkeyLength {
|
||||
return nil, fmt.Errorf("public key must be %d bytes", params.BeaconConfig().BLSPubkeyLength)
|
||||
}
|
||||
@@ -52,9 +48,6 @@ func PublicKeyFromBytes(pubKey []byte) (common.PublicKey, error) {
|
||||
|
||||
// AggregatePublicKeys aggregates the provided raw public keys into a single key.
|
||||
func AggregatePublicKeys(pubs [][]byte) (common.PublicKey, error) {
|
||||
if features.Get().SkipBLSVerify {
|
||||
return &PublicKey{}, nil
|
||||
}
|
||||
if len(pubs) == 0 {
|
||||
return nil, errors.New("nil or empty public keys")
|
||||
}
|
||||
@@ -99,9 +92,6 @@ func (p *PublicKey) Equals(p2 common.PublicKey) bool {
|
||||
|
||||
// Aggregate two public keys.
|
||||
func (p *PublicKey) Aggregate(p2 common.PublicKey) common.PublicKey {
|
||||
if features.Get().SkipBLSVerify {
|
||||
return p
|
||||
}
|
||||
|
||||
agg := new(blstAggregatePublicKey)
|
||||
// No group check here since it is checked at decompression time
|
||||
@@ -114,9 +104,6 @@ func (p *PublicKey) Aggregate(p2 common.PublicKey) common.PublicKey {
|
||||
|
||||
// AggregateMultiplePubkeys aggregates the provided decompressed keys into a single key.
|
||||
func AggregateMultiplePubkeys(pubkeys []common.PublicKey) common.PublicKey {
|
||||
if features.Get().SkipBLSVerify {
|
||||
return &PublicKey{}
|
||||
}
|
||||
mulP1 := make([]*blstPublicKey, 0, len(pubkeys))
|
||||
for _, pubkey := range pubkeys {
|
||||
mulP1 = append(mulP1, pubkey.(*PublicKey).p)
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"crypto/subtle"
|
||||
"fmt"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/config/features"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v3/crypto/bls/common"
|
||||
"github.com/prysmaticlabs/prysm/v3/crypto/rand"
|
||||
@@ -73,9 +72,6 @@ func IsZero(sKey []byte) bool {
|
||||
// In Ethereum proof of stake specification:
|
||||
// def Sign(SK: int, message: Bytes) -> BLSSignature
|
||||
func (s *bls12SecretKey) Sign(msg []byte) common.Signature {
|
||||
if features.Get().SkipBLSVerify {
|
||||
return &Signature{}
|
||||
}
|
||||
signature := new(blstSignature).Sign(s.p, msg, dst)
|
||||
return &Signature{s: signature}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/features"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v3/crypto/bls/common"
|
||||
"github.com/prysmaticlabs/prysm/v3/crypto/rand"
|
||||
@@ -27,9 +26,6 @@ type Signature struct {
|
||||
|
||||
// SignatureFromBytes creates a BLS signature from a LittleEndian byte slice.
|
||||
func SignatureFromBytes(sig []byte) (common.Signature, error) {
|
||||
if features.Get().SkipBLSVerify {
|
||||
return &Signature{}, nil
|
||||
}
|
||||
if len(sig) != fieldparams.BLSSignatureLength {
|
||||
return nil, fmt.Errorf("signature must be %d bytes", fieldparams.BLSSignatureLength)
|
||||
}
|
||||
@@ -57,9 +53,6 @@ func AggregateCompressedSignatures(multiSigs [][]byte) (common.Signature, error)
|
||||
|
||||
// MultipleSignaturesFromBytes creates a group of BLS signatures from a LittleEndian 2d-byte slice.
|
||||
func MultipleSignaturesFromBytes(multiSigs [][]byte) ([]common.Signature, error) {
|
||||
if features.Get().SkipBLSVerify {
|
||||
return []common.Signature{}, nil
|
||||
}
|
||||
if len(multiSigs) == 0 {
|
||||
return nil, fmt.Errorf("0 signatures provided to the method")
|
||||
}
|
||||
@@ -98,9 +91,6 @@ func MultipleSignaturesFromBytes(multiSigs [][]byte) ([]common.Signature, error)
|
||||
// In the Ethereum proof of stake specification:
|
||||
// def Verify(PK: BLSPubkey, message: Bytes, signature: BLSSignature) -> bool
|
||||
func (s *Signature) Verify(pubKey common.PublicKey, msg []byte) bool {
|
||||
if features.Get().SkipBLSVerify {
|
||||
return true
|
||||
}
|
||||
// Signature and PKs are assumed to have been validated upon decompression!
|
||||
return s.s.Verify(false, pubKey.(*PublicKey).p, false, msg, dst)
|
||||
}
|
||||
@@ -123,9 +113,6 @@ func (s *Signature) Verify(pubKey common.PublicKey, msg []byte) bool {
|
||||
//
|
||||
// Deprecated: Use FastAggregateVerify or use this method in spectests only.
|
||||
func (s *Signature) AggregateVerify(pubKeys []common.PublicKey, msgs [][32]byte) bool {
|
||||
if features.Get().SkipBLSVerify {
|
||||
return true
|
||||
}
|
||||
size := len(pubKeys)
|
||||
if size == 0 {
|
||||
return false
|
||||
@@ -154,9 +141,6 @@ func (s *Signature) AggregateVerify(pubKeys []common.PublicKey, msgs [][32]byte)
|
||||
// In the Ethereum proof of stake specification:
|
||||
// def FastAggregateVerify(PKs: Sequence[BLSPubkey], message: Bytes, signature: BLSSignature) -> bool
|
||||
func (s *Signature) FastAggregateVerify(pubKeys []common.PublicKey, msg [32]byte) bool {
|
||||
if features.Get().SkipBLSVerify {
|
||||
return true
|
||||
}
|
||||
if len(pubKeys) == 0 {
|
||||
return false
|
||||
}
|
||||
@@ -179,9 +163,6 @@ func (s *Signature) FastAggregateVerify(pubKeys []common.PublicKey, msg [32]byte
|
||||
// return True
|
||||
// return bls.FastAggregateVerify(pubkeys, message, signature)
|
||||
func (s *Signature) Eth2FastAggregateVerify(pubKeys []common.PublicKey, msg [32]byte) bool {
|
||||
if features.Get().SkipBLSVerify {
|
||||
return true
|
||||
}
|
||||
if len(pubKeys) == 0 && bytes.Equal(s.Marshal(), common.InfiniteSignature[:]) {
|
||||
return true
|
||||
}
|
||||
@@ -199,9 +180,6 @@ func AggregateSignatures(sigs []common.Signature) common.Signature {
|
||||
if len(sigs) == 0 {
|
||||
return nil
|
||||
}
|
||||
if features.Get().SkipBLSVerify {
|
||||
return sigs[0]
|
||||
}
|
||||
|
||||
rawSigs := make([]*blstSignature, len(sigs))
|
||||
for i := 0; i < len(sigs); i++ {
|
||||
@@ -222,9 +200,6 @@ func AggregateSignatures(sigs []common.Signature) common.Signature {
|
||||
// e(S*, G) = \prod_{i=1}^n \prod_{j=1}^{m_i} e(P'_{i,j}, M_{i,j})
|
||||
// Using this we can verify multiple signatures safely.
|
||||
func VerifyMultipleSignatures(sigs [][]byte, msgs [][32]byte, pubKeys []common.PublicKey) (bool, error) {
|
||||
if features.Get().SkipBLSVerify {
|
||||
return true, nil
|
||||
}
|
||||
if len(sigs) == 0 || len(pubKeys) == 0 {
|
||||
return false, nil
|
||||
}
|
||||
@@ -264,10 +239,6 @@ func VerifyMultipleSignatures(sigs [][]byte, msgs [][32]byte, pubKeys []common.P
|
||||
|
||||
// Marshal a signature into a LittleEndian byte slice.
|
||||
func (s *Signature) Marshal() []byte {
|
||||
if features.Get().SkipBLSVerify {
|
||||
return make([]byte, fieldparams.BLSSignatureLength)
|
||||
}
|
||||
|
||||
return s.s.Compress()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user