mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-03 08:37:37 +00:00
168cffb0dd
* check for herumi * clean up * fix tests * fix
73 lines
2.0 KiB
Go
73 lines
2.0 KiB
Go
package bls
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/bls/common"
|
|
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
|
)
|
|
|
|
func TestDisallowZeroSecretKeys(t *testing.T) {
|
|
flags := &featureconfig.Flags{}
|
|
t.Run("herumi", func(t *testing.T) {
|
|
flags := &featureconfig.Flags{}
|
|
reset := featureconfig.InitWithReset(flags)
|
|
defer reset()
|
|
|
|
_, err := SecretKeyFromBytes(common.ZeroSecretKey[:])
|
|
require.Equal(t, common.ErrZeroKey, err)
|
|
})
|
|
|
|
t.Run("blst", func(t *testing.T) {
|
|
flags.EnableBlst = true
|
|
reset := featureconfig.InitWithReset(flags)
|
|
defer reset()
|
|
// Blst does a zero check on the key during deserialization.
|
|
_, err := SecretKeyFromBytes(common.ZeroSecretKey[:])
|
|
require.Equal(t, common.ErrSecretUnmarshal, err)
|
|
})
|
|
}
|
|
|
|
func TestDisallowZeroPublicKeys(t *testing.T) {
|
|
flags := &featureconfig.Flags{}
|
|
|
|
t.Run("herumi", func(t *testing.T) {
|
|
reset := featureconfig.InitWithReset(flags)
|
|
defer reset()
|
|
|
|
_, err := PublicKeyFromBytes(common.InfinitePublicKey[:])
|
|
require.Equal(t, common.ErrInfinitePubKey, err)
|
|
})
|
|
|
|
t.Run("blst", func(t *testing.T) {
|
|
flags.EnableBlst = true
|
|
reset := featureconfig.InitWithReset(flags)
|
|
defer reset()
|
|
|
|
_, err := PublicKeyFromBytes(common.InfinitePublicKey[:])
|
|
require.Equal(t, common.ErrInfinitePubKey, err)
|
|
})
|
|
}
|
|
|
|
func TestDisallowZeroPublicKeys_AggregatePubkeys(t *testing.T) {
|
|
flags := &featureconfig.Flags{}
|
|
|
|
t.Run("herumi", func(t *testing.T) {
|
|
reset := featureconfig.InitWithReset(flags)
|
|
defer reset()
|
|
|
|
_, err := AggregatePublicKeys([][]byte{common.InfinitePublicKey[:], common.InfinitePublicKey[:]})
|
|
require.Equal(t, common.ErrInfinitePubKey, err)
|
|
})
|
|
|
|
t.Run("blst", func(t *testing.T) {
|
|
flags.EnableBlst = true
|
|
reset := featureconfig.InitWithReset(flags)
|
|
defer reset()
|
|
|
|
_, err := AggregatePublicKeys([][]byte{common.InfinitePublicKey[:], common.InfinitePublicKey[:]})
|
|
require.Equal(t, common.ErrInfinitePubKey, err)
|
|
})
|
|
}
|