Repository navigation
perf(core): cached lifted keys in Schnorr verify, BC-native sign - #575
Merged
Merged
Conversation
added 3 commits
November 27, 2026 13:39
Hypothesis: verify -20% and sign -8%: BouncyCastle keeps wNAF tables on the point, so a cached point reuses them and skips the modPow lift.
Hypothesis: sign -5%, pubkey -5%: skip the BigInteger Point round trip (affine pair, mod-2 parity).
… cached keys docs(changelog): note the cached-key verify speedup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #571 (2.4.4). Profiling 2.4.4 from cashu-voucher showed verify still lifting keys with
BigInteger.modPowand BouncyCastle rebuilding its wNAF tables on a fresh point every call.Changes
Schnorr.verifylifts x-only keys through a bounded cache (1024, cleared wholesale when full) of BouncyCastle points configured withWNafUtil.configureBasepoint, so repeat verifies under one key reuse the tables. Off-curve keys are never cached.signandgenPubKeystay on BouncyCastleECPoints (fixed-point comb) instead of round-tripping throughPoint; sign's self-check uses the cached key.PointandSchnorris unchanged.Measurements (AAE harness from #571, 3 runs each, us)
verify -31%, sign -10%, pubkey flat. Harness golden checks pass.
Correctness
SchnorrReferenceTest: a plain BigInteger transcription of the BIP-340 reference; identical signatures and public keys for random inputs, identical verdicts on bit-flipped signatures, other messages, mutated/off-curve keys (checked twice, after caching), r = p, s = n, x >= p and zero keys.