(b *testing.B)
| 166 | } |
| 167 | |
| 168 | func BenchmarkGenKeySignVerify(b *testing.B) { |
| 169 | b.Log(b.Name()) |
| 170 | b.ReportAllocs() |
| 171 | b.ResetTimer() |
| 172 | |
| 173 | for i := 0; i < b.N; i++ { |
| 174 | //hash := make([]byte, 32) |
| 175 | //rand.Read(hash) |
| 176 | hash := []byte("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") |
| 177 | priv, pub, err := GenSecp256k1KeyPair() |
| 178 | if err != nil { |
| 179 | b.Fatalf("error occurred: %v", err) |
| 180 | } |
| 181 | sig, err := priv.Sign(hash[:]) |
| 182 | if err != nil { |
| 183 | b.Fatalf("error occurred: %d, %v", i, err) |
| 184 | } |
| 185 | if !sig.Verify(hash[:], pub) { |
| 186 | b.Fatalf("error occurred: %d", i) |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | func generateKeyPair() (pubkey, privkey []byte) { |
| 192 | key, err := ecdsa.GenerateKey(secp256k1.S256(), crand.Reader) |
nothing calls this directly
no test coverage detected