Files
amethyst/quartz
Claude 6b1bc947a9 perf: eliminate heap allocations in privKeyTweakAdd
Use thread-local scratch LongArrays instead of allocating 2
intermediate LongArray(4) via U256.fromBytes. The old path did:
  fromBytes(seckey) → alloc LongArray(4)
  fromBytes(tweak)  → alloc LongArray(4)
  ScalarN.add(a, b) → alloc LongArray(4)
  U256.toBytes(r)   → alloc ByteArray(32)
  = 4 heap allocations

New path uses pre-allocated scratch from PointScratch:
  fromBytesInto(scratch, seckey) → zero alloc
  fromBytesInto(scratch, tweak) → zero alloc
  ScalarN.addTo(scratch, a, b)  → zero alloc
  U256.toBytes(r)               → 1 alloc (unavoidable, return value)

K/Native: 163 → 88 ns (-46%, from 6.3x to 3.4x vs C)
JVM: now faster than native C via JNI (Kotlin 6.5M ops/s vs C 4.8M ops/s)

https://claude.ai/code/session_015CtM5k88rF7WFgX8o2AGNR
2026-04-09 20:59:58 +00:00
..