Repository navigation
DSA: choose with its generated dispatchers - #4508
Merged
Merged
Conversation
`src/dsa.rs` chose a `Backend` (the baseline or `_adx`) for every key, and parameter generation matched SHA-1's, SHA-256's and the Miller-Rabin round's backends, 27 combinations on x86-64, to name an implementation of `vg_dsa_parameter_search`. Key import, generation, validation, signing, verification and the parameter search now call their `_auto` dispatchers. `Backend`, `Round`, each `select`, the per-ABI `Search` types, the stored backend and their tests go; the parameter search keeps its test of the searcher's steps, through the dispatcher. The `#[cfg(not(any(...)))]` branches for targets outside the module's own were dead: the module exists only on those six architectures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHE2dqL6Q2PDogxfD5f
|
This pull request has conflicts with Posted by |
# Conflicts: # src/dsa.rs
…e CPUs (WIP: crates not yet regenerated) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHE2dqL6Q2PDogxfD5f
…ny position With only the paired SHA-1 and SHA-256 backends, the parameter search's suffixes are `_sha1_avx_bmi_sha256_avx2` and `_sha1_shani_sha256_shani` (and their `_mr_*`): no function with a signature has `_sha1_avx_bmi` alone. `check_variants.py` now takes a qualified part `<tag>_<suffix>` of a variant's suffix, whose `<suffix>` is one, as an internal function's suffix (`vg_dsa_parameter_search_1024_sha1_avx_bmi`), and a callee's variant in any part of a qualified suffix, not only the last. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHE2dqL6Q2PDogxfD5f
alex
enabled auto-merge
November 7, 2026 19:22
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
This was referenced Nov 7, 2026
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.
What changes
DSA chose its implementations in Rust:
src/dsa.rsstored aBackend(the baseline or_adx) in every key.vg_dsa_parameter_searchon x86-64.Key derivation, generation, validation, signing, verification and the parameter search (including its
_init) now call their_autodispatchers.Removed from the Rust:
BackendandRound, eachselectandselect_backends;Searchtypes and the backend stored in keys;The parameter search keeps one test of the searcher's steps,
steps, which runs through the dispatcher.Only the combinations a CPU gets
Of the 27 x86-64 combinations, the dispatcher can choose only some: SHA-1's and SHA-256's code needs the same features in pairs. For example:
The generic registrations (
Generic/{MdHash/MdHash,Sha1/Sha256}/MillerRabin/<T>/Dsa.lean) now pair a SHA-1 and a SHA-256 backend for the same CPUs, as #4502 does for Argon2:_avx_bmiwith_avx2Each pair comes with every Miller–Rabin round, so x86-64 has 9 parameter searches, down from 27.
Two generated dispatcher branches had been covered only by the deleted unit test: IFMA's round without SHA-NI, with SHA-1 AVX/BMI and SHA-256 AVX2, and with both hashes' baselines. To cover them,
ci/rust_matrix.tomlnow runsdsa_parameterson the twoicxlines that have AVX512_IFMA but not SHA.check_variants.pyThe parameter searches' suffixes are now
_sha1_avx_bmi_sha256_avx2and_sha1_shani_sha256_shani(and their_mr_*), with no_sha1_avx_bmialone. Two of the checker's rules matched suffixes too literally, so it now:<tag>_<suffix>of a variant's suffix as an internal function's suffix, when its<suffix>is a variant suffix.vg_dsa_parameter_search_1024_sha1_avx_bmiis the case here;vg_keccak_f1600_x2is still not accepted._sha1_avx_bmi_sha256_avx2. Argon2's_blake2b_avx2_g_avx2only passed before because both its parts end in_avx2.ci/test_check_variants.pyhas a test for each. Both tests fail without the change.No TCB or Spec change.
Benchmark
Run of
dsa:It ran 12 jobs, one per architecture and
VG_CPU_FEATURESconfiguration that chooses an implementation, each with 43 DSA benchmarks. I compared each benchmark's median estimate, head against base, from the uploaded samples:The outliers go both ways, on rows that run the same machine code as before:
dsa_public_key_*anddsa_private_key_*(20–340 ns) move by up to ±36%. Key import calls no verified code: it allocates and copies.dsa_generate_key_*calls the implementation each CPU got before. That includes ARM's +32.9% at 3072 bits, wherevg_dsa_generate_keyhas a single implementation, the same as on main.No benchmark was rerun.
Checks
lake build;Emit.lean(crates regenerated)Static checksstep, includingcheck_variants.pywith its unit testscargo fmt --checkcargo clippy --all-targets -D warningson x86-64, AArch64 and i686VG_CPU_FEATURESunset and set to each of:sha,ssse3,avx,avx2,bmi1,bmi2,adxavx,avx2,bmi1,bmi2,adxavx,bmi1sha,ssse3nonehttps://claude.ai/code/session_01TKUFHE2dqL6Q2PDogxfD5f
Generated by Claude Code