mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-12 01:07:46 +00:00
Two microoptimizations: 1. reduceSelf: exploit P's structure (P[1..3] = 0xFFFFFFFFFFFFFFFF). a >= P only if all top 3 limbs are max AND a[0] >= P[0]. The first check (a[3] == -1) fails >99.99% of the time, making this a single branch miss prediction instead of a 4-limb comparison loop. Called ~1,300× per verify, ~500× per ECDH. 2. Pre-allocate wNAF IntArrays and scratch MutablePoint/LongArray in PointScratch. Eliminates 8-12 IntArray(145) + 8-12 LongArray(4) allocations per mul/mulDoubleG call. Adds wnafInto() to Glv that writes into caller-provided arrays. https://claude.ai/code/session_01BhU63WUe9AhikZxRdw3Lpg