MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / BenchmarkVerify

Function BenchmarkVerify

crypto/asymmetric/signature_test.go:295–424  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

293}
294
295func BenchmarkVerify(b *testing.B) {
296 b.Run("Secp256k1", func(b *testing.B) {
297 b.Log(b.Name())
298 hash := []byte("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
299 sig, err := priv.Sign(hash[:])
300 if err != nil {
301 b.Fatalf("error occurred: %v", err)
302 }
303
304 b.ReportAllocs()
305 b.ResetTimer()
306 for i := 0; i < b.N; i++ {
307 sig.Verify(hash[:], pub)
308 }
309 })
310
311 b.Run("C-Secp256k1", func(b *testing.B) {
312 b.Log(b.Name())
313 hash := []byte("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
314 pubP, privP := generateKeyPair()
315
316 s, err := secp256k1.Sign(hash, privP)
317 if err != nil {
318 b.Fatalf("error occurred: %v", err)
319 }
320
321 b.ReportAllocs()
322 b.ResetTimer()
323 for i := 0; i < b.N; i++ {
324 secp256k1.VerifySignature(pubP, hash, s[:64])
325 }
326 })
327
328 b.Run("P224", func(b *testing.B) {
329 b.Log(b.Name())
330 hash := []byte("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
331 privP, err := ecdsa.GenerateKey(elliptic.P224(), crand.Reader)
332
333 if err != nil {
334 panic(err)
335 }
336 pubP := privP.PublicKey
337
338 r, s, _ := ecdsa.Sign(crand.Reader, privP, hash)
339
340 b.ReportAllocs()
341 b.ResetTimer()
342 for i := 0; i < b.N; i++ {
343 ecdsa.Verify(&pubP, hash, r, s)
344 }
345 })
346
347 b.Run("P256", func(b *testing.B) {
348 b.Log(b.Name())
349 hash := []byte("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
350 privP, err := ecdsa.GenerateKey(elliptic.P256(), crand.Reader)
351
352 if err != nil {

Callers

nothing calls this directly

Calls 8

SignFunction · 0.92
VerifySignatureFunction · 0.92
NameMethod · 0.80
FatalfMethod · 0.80
FatalMethod · 0.80
generateKeyPairFunction · 0.70
SignMethod · 0.65
VerifyMethod · 0.65

Tested by

no test coverage detected