From e47c7f88b9d23b5c2f493cf3c969991928f9bb25 Mon Sep 17 00:00:00 2001 From: kitty Date: Thu, 15 Jul 2021 11:01:21 +0100 Subject: [PATCH] benchmark for bls and ed25519 --- crypto/keys/bls12381/bls12381_test.go | 16 ++++++++++++++++ crypto/keys/ed25519/ed25519_test.go | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/crypto/keys/bls12381/bls12381_test.go b/crypto/keys/bls12381/bls12381_test.go index 7e6cd13a30..c7a9c993aa 100644 --- a/crypto/keys/bls12381/bls12381_test.go +++ b/crypto/keys/bls12381/bls12381_test.go @@ -2,6 +2,7 @@ package bls12381_test import ( "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" + bench "github.com/cosmos/cosmos-sdk/crypto/keys/internal/benchmarking" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" @@ -19,4 +20,19 @@ func TestSignAndValidateBls12381(t *testing.T) { // Test the signature assert.True(t, pubKey.VerifySignature(msg, sig)) +} + + +func BenchmarkSignBls(b *testing.B) { + privKey := bls12381.GenPrivKey() + + bench.BenchmarkSigning(b, privKey) + +} + + +func BenchmarkVerifyBls(b *testing.B) { + privKey := bls12381.GenPrivKey() + + bench.BenchmarkVerification(b, privKey) } \ No newline at end of file diff --git a/crypto/keys/ed25519/ed25519_test.go b/crypto/keys/ed25519/ed25519_test.go index 59cce4066a..4e455c47ad 100644 --- a/crypto/keys/ed25519/ed25519_test.go +++ b/crypto/keys/ed25519/ed25519_test.go @@ -3,6 +3,7 @@ package ed25519_test import ( stded25519 "crypto/ed25519" "encoding/base64" + bench "github.com/cosmos/cosmos-sdk/crypto/keys/internal/benchmarking" "testing" "github.com/stretchr/testify/assert" @@ -228,3 +229,19 @@ func TestMarshalAmino_BackwardsCompatibility(t *testing.T) { }) } } + + + +func BenchmarkSignEd25519(b *testing.B) { + privKey := ed25519.GenPrivKey() + + bench.BenchmarkSigning(b, privKey) + +} + + +func BenchmarkVerifyEd25519(b *testing.B) { + privKey := ed25519.GenPrivKey() + + bench.BenchmarkVerification(b, privKey) +} \ No newline at end of file