Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
richardpringle committed Jan 13, 2025
1 parent 8969119 commit c848a0c
Show file tree
Hide file tree
Showing 7 changed files with 707 additions and 578 deletions.
35 changes: 17 additions & 18 deletions utils/crypto/bls/blstest/bls_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ import (

"github.com/ava-labs/avalanchego/utils"
"github.com/ava-labs/avalanchego/utils/crypto/bls"
"github.com/ava-labs/avalanchego/utils/crypto/bls/signers/localsigner"
)

func BenchmarkSign(b *testing.B) {
privateKey, err := localsigner.NewSigner()
privateKey, err := NewKey()
require.NoError(b, err)
for _, messageSize := range BenchmarkSizes {
b.Run(strconv.Itoa(messageSize), func(b *testing.B) {
Expand All @@ -24,21 +23,21 @@ func BenchmarkSign(b *testing.B) {
b.ResetTimer()

for n := 0; n < b.N; n++ {
_ = privateKey.Sign(message)
_ = Sign(privateKey, message)
}
})
}
}

func BenchmarkVerify(b *testing.B) {
privateKey, err := localsigner.NewSigner()
privateKey, err := NewKey()
require.NoError(b, err)
publicKey := privateKey.PublicKey()
publicKey := PublicKey(privateKey)

for _, messageSize := range BenchmarkSizes {
b.Run(strconv.Itoa(messageSize), func(b *testing.B) {
message := utils.RandomBytes(messageSize)
signature := privateKey.Sign(message)
signature := Sign(privateKey, message)

b.ResetTimer()

Expand All @@ -52,10 +51,10 @@ func BenchmarkVerify(b *testing.B) {
func BenchmarkAggregatePublicKeys(b *testing.B) {
keys := make([]*bls.PublicKey, BiggestBenchmarkSize)
for i := range keys {
privateKey, err := localsigner.NewSigner()
privateKey, err := NewKey()
require.NoError(b, err)

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

for _, size := range BenchmarkSizes {
Expand All @@ -69,10 +68,10 @@ func BenchmarkAggregatePublicKeys(b *testing.B) {
}

func BenchmarkPublicKeyToCompressedBytes(b *testing.B) {
sk, err := localsigner.NewSigner()
sk, err := NewKey()
require.NoError(b, err)

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

b.ResetTimer()
for range b.N {
Expand All @@ -81,10 +80,10 @@ func BenchmarkPublicKeyToCompressedBytes(b *testing.B) {
}

func BenchmarkPublicKeyFromCompressedBytes(b *testing.B) {
sk, err := localsigner.NewSigner()
sk, err := NewKey()
require.NoError(b, err)

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

b.ResetTimer()
Expand All @@ -94,10 +93,10 @@ func BenchmarkPublicKeyFromCompressedBytes(b *testing.B) {
}

func BenchmarkPublicKeyToUncompressedBytes(b *testing.B) {
sk, err := localsigner.NewSigner()
sk, err := NewKey()
require.NoError(b, err)

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

b.ResetTimer()
for range b.N {
Expand All @@ -106,10 +105,10 @@ func BenchmarkPublicKeyToUncompressedBytes(b *testing.B) {
}

func BenchmarkPublicKeyFromValidUncompressedBytes(b *testing.B) {
sk, err := localsigner.NewSigner()
sk, err := NewKey()
require.NoError(b, err)

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

b.ResetTimer()
Expand All @@ -119,11 +118,11 @@ func BenchmarkPublicKeyFromValidUncompressedBytes(b *testing.B) {
}

func BenchmarkSignatureFromBytes(b *testing.B) {
privateKey, err := localsigner.NewSigner()
privateKey, err := NewKey()
require.NoError(b, err)

message := utils.RandomBytes(32)
signature := privateKey.Sign(message)
signature := Sign(privateKey, message)
signatureBytes := bls.SignatureToBytes(signature)

b.ResetTimer()
Expand Down
Loading

0 comments on commit c848a0c

Please sign in to comment.