Skip to content

Instantly share code, notes, and snippets.

@Gustav-Simonsson
Created October 9, 2015 12:55
Show Gist options
  • Select an option

  • Save Gustav-Simonsson/0c520f2e12f7d25e19d5 to your computer and use it in GitHub Desktop.

Select an option

Save Gustav-Simonsson/0c520f2e12f7d25e19d5 to your computer and use it in GitHub Desktop.
secp benchmarks
func BenchmarkSignRandomInput(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)
}
}
}
func BenchmarkSignStaticInput(b *testing.B) {
seckey, _ := hex.DecodeString("1581db03f3238750bfbbc4eba9b90ee5e1448d633fd226586fd050f8c70f9e29")
msg, _ := hex.DecodeString("4941f068cba758a4ff910d2d547e85163c1c69a5786a3991ecfda44ac1fbfcc3")
b.ResetTimer()
for i := 0; i < b.N; i++ {
if _, err := Sign(msg, seckey); err != nil {
b.Fatal(err)
}
}
}
func BenchmarkRecoverRandomInput(b *testing.B) {
_, seckey := GenerateKeyPair()
msg := randentropy.GetEntropyCSPRNG(32)
b.ResetTimer()
for i := 0; i < b.N; i++ {
b.StopTimer()
sig, _ := Sign(msg, seckey)
b.StartTimer()
if _, err := RecoverPubkey(msg, sig); err != nil {
b.Fatal(err)
}
}
}
func BenchmarkRecoverStaticInput(b *testing.B) {
msg, _ := hex.DecodeString("d9f779be0bad14d8bceeb5324ae6c0c39297f2df83835b8b832c0573a349c717")
sig, _ := hex.DecodeString("ee3cc602f19f48e3458b9776807cee77188428b1528249fe6dacd5773f5de70c21a1c89bfe298d9c1361dc8daf1dc406c5b7888203bb155c82ba1817043f11c100")
b.ResetTimer()
for i := 0; i < b.N; i++ {
if _, err := RecoverPubkey(msg, sig); err != nil {
b.Fatal(err)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment