hamadryad-benchmarks.md raw

Gnarl-Hamadryad Benchmarks

AMD Ryzen 5 7520U, linux/amd64, Go 1.24

go test -bench=. ./crypto/ ./crypto/ring/

Hash Functions

BenchmarkTimeOps/secNotes
SHA-256 (32 B)75 ns13.3MStandard reference
SHA-256 (128 B)139 ns7.2MStandard reference
GnarlMid (128 B)2.1 us474K27-byte lattice hash, Z_271
GnarlHash (128 B)2.4 us424K31-byte lattice hash, Z_271
Hamadryad (128 B)65 us15.3K56-byte SWIFFT, Z_257
Hamadryad (1 KB)298 us3.4KMerkle-Damgard chaining
Ring SIS (128 B)70 us14.2KFormal SIS interface

SHA-256 is 15-30x faster per call. Gnarl hashes provide SVP-hard collision resistance and algebraic homomorphism that SHA-256 lacks. The hash cost is amortized in sign/verify where the torus algebra dominates.

Signatures: Schnorr Family

Key Generation

SchemeTimevs BIP-340
Gnarl (SL(2,ZP) torus, Z271)6.5 us10.3x faster
Cayley (SL(2,Zp), Z256)16.4 us4.1x faster
BIP-340 (secp256k1, btcec pure Go)67.1 usbaseline

Signing

SchemeTimevs BIP-340
Gnarl8.3 us25.8x faster
Cayley17.8 us12.0x faster
BIP-340 (btcec)214.4 usbaseline

Verification

SchemeTimevs BIP-340
Gnarl35.8 us4.2x faster
Cayley85.7 us1.7x faster
BIP-340 (btcec)149.5 usbaseline

Wire Sizes

BIP-340GnarlSavings
Secret key32 B27 B-16%
Public key32 B27 B-16%
Signature64 B54 B-16%
Pubkey + sig96 B81 B-16%

Signatures: Ring/GPV (Lattice)

OperationTime
KeyGen12.7 us
Sign33.3 us
Verify9.1 us

GPV verification is the fastest of all signature schemes benchmarked -- 4x faster than Gnarl verify, 16x faster than BIP-340 verify. This is because verification is a single NTT multiply + norm check, no exponentiation.

Key Encapsulation (Ring-LWE KEM)

OperationTime
KeyGen115 us
Encapsulate261 us
Decapsulate423 us

CCA2-secure via Fujisaki-Okamoto transform over Falcon-512 ring (n=512, q=12289). Comparable to ML-KEM/Kyber. Happens once per session -- not the critical path.

Homomorphic Encryption (BGV, HE64 ring)

OperationTimeNotes
Encrypt (1 bit)14.3 us
Add / XOR413 nsLinear, no noise blowup
Multiply / AND54.8 usQuadratic noise, requires relinearization

HE64 ring: n=64, q=10,000,769. Depth-1 multiplicative circuits. Addition is ~130x cheaper than multiplication because it's just coefficient-wise add with no relinearization.

Authenticated Encryption (GnarlWire)

OperationTime
Seal (128 B)41.1 us
Open (128 B)39.2 us

ChaCha20 + GnarlMid MAC. 64-byte fixed header. Symmetric, so these are the per-packet costs for encrypted transport.

Ring Internals

OperationTime
NTT-27 (forward)289 ns
INTT-27 (inverse)265 ns
mod 2710.25 ns
Gnarl compress482 ns

The n=27 NTT completes in under 300 ns. This is the core operation that would need to run in-EVM for on-chain verification. At ~135 mulmod operations per transform, this is tractable.