mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-12 09:13:23 +00:00
The comb method (Hamburg 2012) replaces GLV+wNAF for generator multiplication. Instead of ~130 doublings + ~32 additions, it arranges the 256 scalar bits into a 4×66 matrix and processes each of 4 rows with 11 table lookups. Only 3 doublings are needed between rows. Algorithm: COMB_BLOCKS=11, COMB_TEETH=6, COMB_SPACING=4 - 11 blocks × 64 entries = 704 affine points (~45KB), lazily precomputed - Per mulG: 3 doublings + ~43 mixed additions ≈ 464 M-equiv - Previous GLV+wNAF: ~130 doublings + ~32 additions ≈ 1,035 M-equiv - Theoretical speedup: 2.2× (measured: 2.0-2.1×) Table construction uses an efficient Gray-code-like ordering: each successive mask differs by one bit, so each entry is built from the previous with one point addition instead of summing all teeth from scratch. Benchmark improvements: pubkeyCreate: 8,383 → 17,654 ops/s (2.1×, now 3.6× vs native) signSchnorr (cached): 7,411 → 13,642 ops/s (1.8×, now 2.3× vs native) signSchnorr: 3,257 → 5,856 ops/s (1.8×, now 4.8× vs native) compressedPubKeyFor: 8,475 → 16,695 ops/s (2.0×, now 3.1× vs native) https://claude.ai/code/session_01BhU63WUe9AhikZxRdw3Lpg