Skip to content

Commit

Permalink
Straglers
Browse files Browse the repository at this point in the history
  • Loading branch information
richardpringle committed Nov 27, 2024
1 parent 72e2bba commit fd5e553
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 49 deletions.
12 changes: 6 additions & 6 deletions utils/crypto/bls/bls_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func BenchmarkSign(b *testing.B) {
func BenchmarkVerify(b *testing.B) {
privateKey, err := NewSigner()
require.NoError(b, err)
publicKey := PublicKey(privateKey)
publicKey := privateKey.PublicKey()

for _, messageSize := range sizes {
b.Run(strconv.Itoa(messageSize), func(b *testing.B) {
Expand All @@ -75,7 +75,7 @@ func BenchmarkAggregatePublicKeys(b *testing.B) {
privateKey, err := NewSigner()
require.NoError(b, err)

keys[i] = PublicKey(privateKey)
keys[i] = privateKey.PublicKey()
}

for _, size := range sizes {
Expand All @@ -92,7 +92,7 @@ func BenchmarkPublicKeyToCompressedBytes(b *testing.B) {
sk, err := NewSigner()
require.NoError(b, err)

pk := PublicKey(sk)
pk := sk.PublicKey()

b.ResetTimer()
for range b.N {
Expand All @@ -104,7 +104,7 @@ func BenchmarkPublicKeyFromCompressedBytes(b *testing.B) {
sk, err := NewSigner()
require.NoError(b, err)

pk := PublicKey(sk)
pk := sk.PublicKey()
pkBytes := PublicKeyToCompressedBytes(pk)

b.ResetTimer()
Expand All @@ -117,7 +117,7 @@ func BenchmarkPublicKeyToUncompressedBytes(b *testing.B) {
sk, err := NewSigner()
require.NoError(b, err)

pk := PublicKey(sk)
pk := sk.PublicKey()

b.ResetTimer()
for range b.N {
Expand All @@ -129,7 +129,7 @@ func BenchmarkPublicKeyFromValidUncompressedBytes(b *testing.B) {
sk, err := NewSigner()
require.NoError(b, err)

pk := PublicKey(sk)
pk := sk.PublicKey()
pkBytes := PublicKeyToUncompressedBytes(pk)

b.ResetTimer()
Expand Down
64 changes: 32 additions & 32 deletions utils/crypto/bls/bls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ func TestAggregation(t *testing.T) {
require.NoError(err)

pks := []*PublicKey{
PublicKey(sk0),
PublicKey(sk1),
PublicKey(sk2),
sk0.PublicKey(),
sk1.PublicKey(),
sk2.PublicKey(),
}

msg := utils.RandomBytes(1234)
Expand All @@ -56,7 +56,7 @@ func TestAggregation(t *testing.T) {
require.NoError(err)

pks := []*PublicKey{
PublicKey(sk),
sk.PublicKey(),
}

msg := utils.RandomBytes(1234)
Expand All @@ -80,9 +80,9 @@ func TestAggregation(t *testing.T) {
require.NoError(err)

pks := []*PublicKey{
PublicKey(sk0),
PublicKey(sk1),
PublicKey(sk2),
sk0.PublicKey(),
sk1.PublicKey(),
sk2.PublicKey(),
}

msg := utils.RandomBytes(1234)
Expand Down Expand Up @@ -110,9 +110,9 @@ func TestAggregation(t *testing.T) {
require.NoError(err)

pks := []*PublicKey{
PublicKey(sk0),
PublicKey(sk1),
PublicKey(sk2),
sk0.PublicKey(),
sk1.PublicKey(),
sk2.PublicKey(),
}

msg := utils.RandomBytes(1234)
Expand Down Expand Up @@ -141,9 +141,9 @@ func TestAggregation(t *testing.T) {
require.NoError(err)

pks := []*PublicKey{
PublicKey(sk0),
PublicKey(sk1),
PublicKey(sk3),
sk0.PublicKey(),
sk1.PublicKey(),
sk3.PublicKey(),
}

msg := utils.RandomBytes(1234)
Expand All @@ -169,9 +169,9 @@ func TestAggregation(t *testing.T) {
require.NoError(err)

pks := []*PublicKey{
PublicKey(sk0),
PublicKey(sk1),
PublicKey(sk2),
sk0.PublicKey(),
sk1.PublicKey(),
sk2.PublicKey(),
}

msg := utils.RandomBytes(1234)
Expand All @@ -196,8 +196,8 @@ func TestAggregation(t *testing.T) {
require.NoError(err)

pks := []*PublicKey{
PublicKey(sk0),
PublicKey(sk1),
sk0.PublicKey(),
sk1.PublicKey(),
}

msg := utils.RandomBytes(1234)
Expand Down Expand Up @@ -246,9 +246,9 @@ func TestAggregation(t *testing.T) {
require.NoError(err)

pks := []*PublicKey{
PublicKey(sk0),
PublicKey(sk1),
PublicKey(sk2),
sk0.PublicKey(),
sk1.PublicKey(),
sk2.PublicKey(),
}

msg := utils.RandomBytes(1234)
Expand Down Expand Up @@ -290,9 +290,9 @@ func TestAggregationThreshold(t *testing.T) {

// All the public keys would be registered on chain
pks := []*PublicKey{
PublicKey(sk0),
PublicKey(sk1),
PublicKey(sk2),
sk0.PublicKey(),
sk1.PublicKey(),
sk2.PublicKey(),
}

// The transaction's unsigned bytes are publicly known.
Expand Down Expand Up @@ -350,7 +350,7 @@ func TestVerify(t *testing.T) {
setup: func(require *require.Assertions) (*PublicKey, *Signature, []byte) {
sk, err := NewSigner()
require.NoError(err)
pk := PublicKey(sk)
pk := sk.PublicKey()
msg := utils.RandomBytes(1234)
sig := sk.Sign(msg)
return pk, sig, msg
Expand All @@ -362,7 +362,7 @@ func TestVerify(t *testing.T) {
setup: func(require *require.Assertions) (*PublicKey, *Signature, []byte) {
sk, err := NewSigner()
require.NoError(err)
pk := PublicKey(sk)
pk := sk.PublicKey()
msg := utils.RandomBytes(1234)
sig := sk.Sign(msg)
msg[0]++
Expand All @@ -380,7 +380,7 @@ func TestVerify(t *testing.T) {

sk2, err := NewSigner()
require.NoError(err)
pk := PublicKey(sk2)
pk := sk2.PublicKey()
return pk, sig, msg
},
expectedValid: false,
Expand All @@ -390,7 +390,7 @@ func TestVerify(t *testing.T) {
setup: func(require *require.Assertions) (*PublicKey, *Signature, []byte) {
sk, err := NewSigner()
require.NoError(err)
pk := PublicKey(sk)
pk := sk.PublicKey()
msg := utils.RandomBytes(1234)

msg2 := utils.RandomBytes(1234)
Expand Down Expand Up @@ -426,7 +426,7 @@ func TestVerifyProofOfPossession(t *testing.T) {
setup: func(require *require.Assertions) (*PublicKey, *Signature, []byte) {
sk, err := NewSigner()
require.NoError(err)
pk := PublicKey(sk)
pk := sk.PublicKey()
msg := utils.RandomBytes(1234)
sig := sk.SignProofOfPossession(msg)
return pk, sig, msg
Expand All @@ -438,7 +438,7 @@ func TestVerifyProofOfPossession(t *testing.T) {
setup: func(require *require.Assertions) (*PublicKey, *Signature, []byte) {
sk, err := NewSigner()
require.NoError(err)
pk := PublicKey(sk)
pk := sk.PublicKey()
msg := utils.RandomBytes(1234)
sig := sk.SignProofOfPossession(msg)
msg[0]++
Expand All @@ -456,7 +456,7 @@ func TestVerifyProofOfPossession(t *testing.T) {

sk2, err := NewSigner()
require.NoError(err)
pk := PublicKey(sk2)
pk := sk2.PublicKey()
return pk, sig, msg
},
expectedValid: false,
Expand All @@ -466,7 +466,7 @@ func TestVerifyProofOfPossession(t *testing.T) {
setup: func(require *require.Assertions) (*PublicKey, *Signature, []byte) {
sk, err := NewSigner()
require.NoError(err)
pk := PublicKey(sk)
pk := sk.PublicKey()
msg := utils.RandomBytes(1234)

msg2 := utils.RandomBytes(1234)
Expand Down
4 changes: 2 additions & 2 deletions utils/crypto/bls/public_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestPublicKeyBytes(t *testing.T) {
sk, err := NewSigner()
require.NoError(err)

pk := PublicKey(sk)
pk := sk.PublicKey()
pkBytes := PublicKeyToCompressedBytes(pk)

pk2, err := PublicKeyFromCompressedBytes(pkBytes)
Expand All @@ -42,7 +42,7 @@ func TestAggregatePublicKeysNoop(t *testing.T) {
sk, err := NewSigner()
require.NoError(err)

pk := PublicKey(sk)
pk := sk.PublicKey()
pkBytes := PublicKeyToCompressedBytes(pk)

aggPK, err := AggregatePublicKeys([]*PublicKey{pk})
Expand Down
4 changes: 2 additions & 2 deletions utils/crypto/bls/secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ func TestSecretKeyBytes(t *testing.T) {
sk, err := NewSigner()
require.NoError(err)
sig := sk.Sign(msg)
skBytes := ToBytes(sk)
skBytes := sk.ToBytes()

sk2, err := SecretKeyFromBytes(skBytes)
require.NoError(err)
sig2 := sk2.Sign(msg)
sk2Bytes := ToBytes(sk2)
sk2Bytes := sk2.ToBytes()

require.Equal(sk, sk2)
require.Equal(skBytes, sk2Bytes)
Expand Down
4 changes: 2 additions & 2 deletions vms/platformvm/network/warp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func TestSignatureRequestVerifyL1ValidatorRegistrationRegistered(t *testing.T) {
ValidationID: ids.GenerateTestID(),
SubnetID: ids.GenerateTestID(),
NodeID: ids.GenerateTestNodeID(),
PublicKey: bls.PublicKeyToUncompressedBytes(sk).PublicKey(),
PublicKey: bls.PublicKeyToUncompressedBytes(sk.PublicKey()),
Weight: 1,
}
state = statetest.New(t, statetest.Config{})
Expand Down Expand Up @@ -556,7 +556,7 @@ func TestSignatureRequestVerifyL1ValidatorWeight(t *testing.T) {
ValidationID: ids.GenerateTestID(),
SubnetID: ids.GenerateTestID(),
NodeID: ids.GenerateTestNodeID(),
PublicKey: bls.PublicKeyToUncompressedBytes(sk).PublicKey(),
PublicKey: bls.PublicKeyToUncompressedBytes(sk.PublicKey()),
Weight: weight,
MinNonce: nonce + 1,
}
Expand Down
4 changes: 2 additions & 2 deletions vms/platformvm/txs/executor/standard_tx_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2653,7 +2653,7 @@ func TestStandardExecutorConvertSubnetToL1Tx(t *testing.T) {

var (
validationID = subnetID.Append(0)
pkBytes = bls.PublicKeyToUncompressedBytes(sk).PublicKey()
pkBytes = bls.PublicKeyToUncompressedBytes(sk.PublicKey())
)
remainingBalanceOwner, err := txs.Codec.Marshal(txs.CodecVersion, &validator.RemainingBalanceOwner)
require.NoError(err)
Expand Down Expand Up @@ -3100,7 +3100,7 @@ func TestStandardExecutorRegisterL1ValidatorTx(t *testing.T) {
ValidationID: ids.GenerateTestID(),
SubnetID: subnetID,
NodeID: nodeID,
PublicKey: bls.PublicKeyToUncompressedBytes(initialSK).PublicKey(),
PublicKey: bls.PublicKeyToUncompressedBytes(initialSK.PublicKey()),
Weight: 1,
})
},
Expand Down
2 changes: 1 addition & 1 deletion vms/platformvm/txs/executor/warp_verifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestVerifyWarpMessages(t *testing.T) {
var (
subnetID = ids.GenerateTestID()
chainID = ids.GenerateTestID()
newValidator = func() (*bls.SecretKey, *validators.GetValidatorOutput) {
newValidator = func() (bls.Signer, *validators.GetValidatorOutput) {
sk, err := bls.NewSigner()
require.NoError(t, err)

Expand Down
2 changes: 1 addition & 1 deletion vms/platformvm/warp/gwarp/signer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
type testSigner struct {
client *Client
server warp.Signer
sk *bls.SecretKey
sk bls.Signer
networkID uint32
chainID ids.ID
}
Expand Down
2 changes: 1 addition & 1 deletion vms/platformvm/warp/signature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var (

type testValidator struct {
nodeID ids.NodeID
sk *bls.SecretKey
sk bls.Signer
vdr *Validator
}

Expand Down

0 comments on commit fd5e553

Please sign in to comment.