Repository navigation
Conversation
alex
force-pushed
the
claude/ppc64le-dsa-r2
branch
from
November 8, 2026 20:41
f8299ff to
c14404e
Compare
alex
force-pushed
the
claude/ppc64le-dsa-prime-r2
branch
from
November 8, 2026 20:41
abfa4cd to
0edfcd7
Compare
The probable-prime test of `bits` bits set up Montgomery arithmetic with `Search.montPrep`, which computes R² mod c by 128 w doublings. A candidate of `bits` bits is above 2^(bits-1), so when 64 (w - 1) < bits its top word cannot be zero and `Precompute.r2Hi` (64 + w doublings and six Montgomery squares) applies. That holds for every size but a 160-bit q, whose four words leave the top one empty. `montPrepFor bits` chooses `Search.montPrepHi` or `Search.montPrep` when the code is built, so the test has no new branch, and its constant-time proof taints each choice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHEf743DNZVAyToasZ6
alex
force-pushed
the
claude/ppc64le-dsa-prime-r2
branch
from
November 8, 2026 21:25
0edfcd7 to
2bbd757
Compare
alex
marked this pull request as ready for review
November 8, 2026 21:25
Member
Author
|
Closing this: a 1.5–2.5% gain on DSA parameter generation isn't worth a second Montgomery-setup path and its proofs to maintain. Most of the remaining time is in the Miller–Rabin rounds, which the bignum work will speed up for parameter generation too. Generated by Claude Code |
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.
Part of #4141 (finding 7 of the PPC64LE audit: DSA parameter generation). #4678 has merged, and this branch is restacked onto
main(fbc66f8). It changes noSpec/orTCB/file and no Rust code outside the generated PPC64LE crate.What was slow
Each probable-prime test (
vg_dsa_probable_prime_{bits}) that gets past trial division sets up Montgomery arithmetic modulo the candidate withSearch.montPrep. That computes R² mod c by 128·w modular doublings. #4678 removed the same cost fromsetupP.What changed
montPrepFor bits(Impl/Dsa/PPC64LE/ProbablePrime.lean) isSearch.montPrepHiwhen64 (w − 1) < bits, andSearch.montPrepotherwise.montPrepHiismontPrepWith Precompute.r2Hi: 64 + w doublings and six Montgomery squares.bitsbits is above 2^(bits−1), so under that condition its top word cannot be zero, which is whatr2Hineeds.montPrep, because 160 bits use only part of its four words.vg_dsa_probable_prime_160is unchanged.Proofs:
montPrepFor_ctx(Prime/Body.lean) getsr2Hi's precondition from the candidate's bit length (bitLength_iff_bounds, and the candidate is odd). It goes throughprepWith_ctx, which is the oldmontPrep_ctxgeneralized overR2Ok r2c P.body_cttaints each of the two choices.prime_stackcovers the stack depth of either choice.Numbers
Benchmarks run 42521440680: POWER9,
dsa_generate_parameters, base = #4678's head (c14404e), one run of each side, measured before the restack.dsa_generate_parameters/1024dsa_generate_parameters/2048dsa_generate_parameters/3072That is about what the R² setup's share predicted (roughly 5% of parameter generation). The Miller–Rabin rounds, which belong to the bignum work, dominate the rest.
Checks
lake buildof the whole project (on main's CI cache) passes, and the full emitter leaves the tree clean. The Static checks pass.check_lean_public_imports.pyis OK on the edited modules.cargo check --target powerpc64le-unknown-linux-gnu --libbuilds the crate. CI's ppc64le jobs run the tests.🤖 Generated with Claude Code
https://claude.ai/code/session_01TKUFHEf743DNZVAyToasZ6