f476168f60
In Nostr, the same pubkeys are verified repeatedly (many events per author). Building the P-side wNAF table costs ~437 field ops (~27% of verify). This cache stores precomputed affine tables keyed by pubkey x-coordinate, skipping table build entirely on cache hits. 1024 cache entries × 16 affine points × 64 bytes ≈ 1MB total. Direct-mapped hash: (px.d[0] ^ (px.d[1] << 3)) & 1023. Performance with cached pubkey (x86_64 standalone): verifyFast: 51.5 → 35.4 µs (1.46x faster, 28,242 ops/s) verify: 58.3 → 42.0 µs (1.39x faster, 23,820 ops/s) Now FASTER than ACINQ's libsecp256k1 for cached-pubkey verify: ACINQ: 25,832 ops/s (38.7 µs) Ours: 28,242 ops/s (35.4 µs) https://claude.ai/code/session_011KVZhDcV2G7idNWEBz12GY