Repository navigation
RISC-V: reduce Montgomery and private RSA overhead - #4514
Merged
Merged
Conversation
|
This pull request has conflicts with Posted by |
reaperhulk
force-pushed
the
perf/riscv-rsa-private
branch
from
November 7, 2026 18:39
19c5f7f to
40ab9d8
Compare
reaperhulk
enabled auto-merge
November 7, 2026 18:41
alex
pushed a commit
that referenced
this pull request
Nov 7, 2026
Resolves the conflict with #4508: src/dsa/parameters/search.rs and its tests take main's dispatchers, and riscv64 joins search.rs's module gate. The RISC-V crate is regenerated with the full emitter, which picks up #4514's Montgomery code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHGhkN8REQLPW8yxN5A
alex
pushed a commit
that referenced
this pull request
Nov 7, 2026
Main removed declarations only this branch still used (#4336, #4367, #4514): `fin64_exec_li_lit`, the RISC-V Miller–Rabin search pieces the sieved parameter candidate calls, and three of `ModExpWin`'s WP lemmas. They return, unchanged, as FFDH-only modules (`Proof/Ffdh/RISCV64/Li.lean`, `Impl/Ffdh/RISCV64/Search.lean`, `Proof/Ffdh/RISCV64/Search.lean`) and local lemmas in `Cached/Rows.lean`. The registrations drop `consts :=` (#4380). The generated code takes #4514's Montgomery schedule and #4468's dispatcher. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHHEKNw8eCDhgbwoFBL
alex
pushed a commit
that referenced
this pull request
Nov 15, 2026
Main removed declarations only this branch still used (#4336, #4367, #4514): `fin64_exec_li_lit`, the RISC-V Miller–Rabin search pieces the sieved parameter candidate calls, and three of `ModExpWin`'s WP lemmas. They return, unchanged, as FFDH-only modules (`Proof/Ffdh/RISCV64/Li.lean`, `Impl/Ffdh/RISCV64/Search.lean`, `Proof/Ffdh/RISCV64/Search.lean`) and local lemmas in `Cached/Rows.lean`. The registrations drop `consts :=` (#4380). The generated code takes #4514's Montgomery schedule and #4468's dispatcher. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHHEKNw8eCDhgbwoFBL
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.
Private RSA repeatedly copies whole table entries while selecting each exponent window and serializes Montgomery product work. Scan all 16 entries for each output word and store that word once, schedule independent
mulhu/mulpairs high first in FIOS multiplication, and pipeline squaring pairs using only the caller-saveda4temporary. The square schedule overlaps the next low product with the current carry chain without stack spills or additional instructions.Extend the row and window-selection proofs through the existing RSA correctness, memory-safety, ABI, and constant-time contracts. Regenerate all RISC-V consumers of the shared Montgomery routines, including DSA and Miller–Rabin. No specification, ISA model, workspace size, or stack allocation changes.
Native cached-key PKCS#1 SHA-256 signing and verification (benchmark run and raw estimates), comparing
85a4ddeb333c(#4500) with19c5f7f859fe:The table uses the fastest Criterion median of three interleaved runs per revision on the same native
riscv64gc-unknown-linux-gnurunner (1.848 GHz, Rust 1.99.0). Every paired round improved: signing reductions ranged from 2.8–4.7%, verification from 1.5–4.0%. These are single-thread operation timings. This square schedule uses fewer temporaries than the earlier prototype; the numbers above measure the proved implementation itself.Reproduce:
gh workflow run bench.yml --ref perf/riscv-rsa-private \ -f base_commit=85a4ddeb333cc681b014065ed2130ba78d9da2d5 \ -f arches=riscv64 -f modules=rsa_pkcs1_sig \ -f 'groups=rsa_pkcs1_(sign|verify)' -f rounds=3Validation: full
lake buildpassed after rebasing (28,606 jobs); all static checks and 660 CI unit tests passed; import analysis passed; complete RISC-V emission passed the standard axiom/compiler/spec-origin audits and byte-for-byte--check. Native RISC-V Rust tests and both Rust lint jobs passed on the benchmarked revision; CI is rerunning after the rebase.#4500 has merged. This PR now targets
mainand contains only the Montgomery/private-RSA changes. Rebased head40ab9d865482has byte-identical generated RISC-V assembly to the benchmarked19c5f7f859fe; the complete emitter audit and byte-for-byte check passed again after the rebase.