diff options
author | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-09-28 17:19:23 +0800 |
---|---|---|
committer | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-11-30 20:24:04 +0800 |
commit | 27a50c8f4bc69f98e20db361859bfbb6cf371c00 (patch) | |
tree | a7440f35ed0940cb87d2b17b53177b05afaa51aa /crypto/secp256k1/secp256_test.go | |
parent | 66d47ced4892141cdc955856b9fce6e95bca0402 (diff) | |
download | dexon-27a50c8f4bc69f98e20db361859bfbb6cf371c00.tar dexon-27a50c8f4bc69f98e20db361859bfbb6cf371c00.tar.gz dexon-27a50c8f4bc69f98e20db361859bfbb6cf371c00.tar.bz2 dexon-27a50c8f4bc69f98e20db361859bfbb6cf371c00.tar.lz dexon-27a50c8f4bc69f98e20db361859bfbb6cf371c00.tar.xz dexon-27a50c8f4bc69f98e20db361859bfbb6cf371c00.tar.zst dexon-27a50c8f4bc69f98e20db361859bfbb6cf371c00.zip |
core/secp256k1: update libsecp256k1 Go wrapper and tests
Diffstat (limited to 'crypto/secp256k1/secp256_test.go')
-rw-r--r-- | crypto/secp256k1/secp256_test.go | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/crypto/secp256k1/secp256_test.go b/crypto/secp256k1/secp256_test.go index cb71ea5e7..d3ff2223d 100644 --- a/crypto/secp256k1/secp256_test.go +++ b/crypto/secp256k1/secp256_test.go @@ -86,10 +86,7 @@ func TestSignAndRecover(t *testing.T) { func TestRandomMessagesWithSameKey(t *testing.T) { pubkey, seckey := GenerateKeyPair() keys := func() ([]byte, []byte) { - // Sign function zeroes the privkey so we need a new one in each call - newkey := make([]byte, len(seckey)) - copy(newkey, seckey) - return pubkey, newkey + return pubkey, seckey } signAndRecoverWithRandomMessages(t, keys) } @@ -209,30 +206,32 @@ func compactSigCheck(t *testing.T, sig []byte) { } } -// godep go test -v -run=XXX -bench=BenchmarkSignRandomInputEachRound +// godep go test -v -run=XXX -bench=BenchmarkSign // add -benchtime=10s to benchmark longer for more accurate average -func BenchmarkSignRandomInputEachRound(b *testing.B) { + +// to avoid compiler optimizing the benchmarked function call +var err error + +func BenchmarkSign(b *testing.B) { for i := 0; i < b.N; i++ { - b.StopTimer() _, seckey := GenerateKeyPair() msg := randentropy.GetEntropyCSPRNG(32) b.StartTimer() - if _, err := Sign(msg, seckey); err != nil { - b.Fatal(err) - } + _, e := Sign(msg, seckey) + err = e + b.StopTimer() } } -//godep go test -v -run=XXX -bench=BenchmarkRecoverRandomInputEachRound -func BenchmarkRecoverRandomInputEachRound(b *testing.B) { +//godep go test -v -run=XXX -bench=BenchmarkECRec +func BenchmarkRecover(b *testing.B) { for i := 0; i < b.N; i++ { - b.StopTimer() _, seckey := GenerateKeyPair() msg := randentropy.GetEntropyCSPRNG(32) sig, _ := Sign(msg, seckey) b.StartTimer() - if _, err := RecoverPubkey(msg, sig); err != nil { - b.Fatal(err) - } + _, e := RecoverPubkey(msg, sig) + err = e + b.StopTimer() } } |