BENCHMARK_RESULTS.md raw

Benchmark Results

System Information

Benchmark Results Summary

All benchmarks were run with -benchtime=2s to ensure stable results. Results show:

Context Operations

Operationns/opB/opallocs/op
ContextCreate8.52411
ContextRandomize2.54500

ECDSA Operations

Operationns/opB/opallocs/op
ECDSASign5,039,5032,22639
ECDSAVerify9,790,87800
ECDSASignCompact5,143,8872,29040
ECDSAVerifyCompact10,349,14300

Performance Notes:

Key Generation Operations

Operationns/opB/opallocs/op
ECSeckeyGenerate548.4321
ECKeyPairGenerate5,109,935962

Performance Notes:

Hash Functions

Operationns/opB/opallocs/op
SHA256 (64 bytes)150.41442
HMACSHA256 (64 bytes)517.04167
RFC6979 (nonce generation)2,8402,16238
TaggedHash (BIP-340 style)309.73205

Performance Notes:

Elliptic Curve Operations

Operationns/opB/opallocs/op
GroupDouble203.700
GroupAdd38,66700
ECPubkeyCreate1,259,57800
ECPubkeySerializeCompressed64.9000
ECPubkeyParse6,59500

Performance Notes:

Performance Analysis

Signing Performance (~5ms)

The signing operation includes:

  1. RFC6979 nonce generation (~2.8μs)
  2. Scalar multiplication nonce * G (~1.3ms)
  3. Field element and scalar operations (~3.7ms)
  4. Memory allocations for intermediate values (~2.2KB)

Verification Performance (~10ms)

The verification operation includes:

  1. Two scalar inversions (~2ms each)
  2. Two scalar multiplications (~4ms total)
  3. Point addition (~39μs)
  4. Field element operations (~4ms)
  5. Zero memory allocations (zero-copy)

Memory Usage

Comparison with C Reference Implementation

Based on typical secp256k1 C library benchmarks:

The performance difference is expected due to:

Recommendations

  1. For Production Use: Performance is acceptable for most applications (~5ms signing, ~10ms verification)
  2. For High-Throughput: Consider caching contexts and pre-computed values
  3. Memory Optimization: Verification already uses zero allocations; signing could be optimized further
  4. Batch Operations: Future optimizations could include batch signing/verification

Running Benchmarks

To regenerate these results:

go test -bench=. -benchmem -benchtime=2s | tee benchmark_results.txt

For more detailed profiling:

go test -bench=. -benchmem -cpuprofile=cpu.prof -memprofile=mem.prof
go tool pprof cpu.prof
go tool pprof mem.prof