mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00: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:
parent
faa0643b16
commit
5ad36486b0
@ -43,7 +43,6 @@ type Flags struct {
|
||||
// Feature related flags.
|
||||
RemoteSlasherProtection bool // RemoteSlasherProtection utilizes a beacon node with --slasher mode for validator slashing protection.
|
||||
WriteSSZStateTransitions bool // WriteSSZStateTransitions to tmp directory.
|
||||
SkipBLSVerify bool // Skips BLS verification across the runtime.
|
||||
EnablePeerScorer bool // EnablePeerScorer enables experimental peer scoring in p2p.
|
||||
EnableLargerGossipHistory bool // EnableLargerGossipHistory increases the gossip history we store in our caches.
|
||||
WriteWalletPasswordOnWebOnboarding bool // WriteWalletPasswordOnWebOnboarding writes the password to disk after Prysm web signup.
|
||||
|
@ -12,7 +12,6 @@ go_library(
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//beacon-chain/core/signing:go_default_library",
|
||||
"//config/features:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//crypto/bls:go_default_library",
|
||||
"//crypto/hash:go_default_library",
|
||||
|
@ -5,7 +5,6 @@ package deposit
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/signing"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/features"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v3/crypto/bls"
|
||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
||||
@ -79,9 +78,6 @@ func WithdrawalCredentialsHash(withdrawalKey bls.SecretKey) []byte {
|
||||
|
||||
// VerifyDepositSignature verifies the correctness of Eth1 deposit BLS signature
|
||||
func VerifyDepositSignature(dd *ethpb.Deposit_Data, domain []byte) error {
|
||||
if features.Get().SkipBLSVerify {
|
||||
return nil
|
||||
}
|
||||
ddCopy := ethpb.CopyDepositData(dd)
|
||||
publicKey, err := bls.PublicKeyFromBytes(ddCopy.PublicKey)
|
||||
if err != nil {
|
||||
|
@ -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()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user