Repository navigation
ML-DSA PPC64LE: prepared keys for many signatures and verifications - #4386
Conversation
|
The red "Compare with base (powerpc64)" check comes from the manual Benchmarks run, and it's the expected cost of this change, not a regression. Its >35% gate fires only on Generated by Claude Code |
|
This pull request has conflicts with Posted by |
4209a03 to
35ae2de
Compare
|
This pull request has conflicts with Posted by |
35ae2de to
d906cda
Compare
|
This pull request has conflicts with Posted by |
d906cda to
53eff68
Compare
|
This pull request has conflicts with Posted by |
53eff68 to
eafcd74
Compare
PPC64LE implementations, verified, of the prepared-key functions whose
specification is Spec/MlDsa/PreparedKey.lean, as AArch64 has them:
* vg_mldsa{44,65,87}_prepare_signing_key and _prepare_verifying_key
(a new registration file, Artifacts/MlDsaPreparedKey/PPC64LE.lean): the
encoded key copied, then each of its polynomials unpacked and transformed
with vg_mldsa_ntt.
* vg_mldsa*_sign_message_prepared and _verify_message_prepared, the message
functions' code calling vg_mldsa*_sign_prepared and _verify_prepared.
The ordinary and prepared entries share one kernel per parameter set,
vg_mldsa*_sign_with_cache and vg_mldsa*_verify_with_cache (internal, with
their untrusted contracts in Proof/MlDsa/PreparedKeyContract.lean): signing
copies s1, s2 and t0 from the cache instead of decoding them when its length
is nonzero, and verification copies NTT(t1 * 2^d) for each row. The message
proofs are generalized over the key kind, and the prepared contracts'
satisfiability comes from the memory the verified preparation writes.
The Rust prepared key types use these functions on PPC64LE.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ajQWuKibVLbRQDRNZ3SgM
eafcd74 to
0f40e85
Compare
Follows #4375 (AArch64), #4387 (ARMv7) and #4366 (the specification). It brings verified prepared ML-DSA keys to PPC64LE. There's only a baseline implementation there, so there are no CPU-feature variants to cover. This was stacked on #4387 while both were open; now that #4387 has merged, it's based on
mainagain.Is it worth it on PPC64LE?
I measured this before writing any code, by counting instructions under QEMU (
-one-insn-per-tb). The work a prepared key removes, decoding the key plus its NTTs, is this share of each operation:That's somewhat more than AArch64's 4–7%, and the benchmarks below agree.
Verified code (PPC64LE)
Artifacts/MlDsaPreparedKey/PPC64LE.leanregistersvg_mldsa*_prepare_{signing,verifying}_key. Each copies the encoded key with the gathers' doubleword loop, then for each polynomial unpacks it into its slot (vg_mldsa_bit_unpack/vg_mldsa_unpack_t1) and transforms it there (vg_mldsa_ntt).MlDsaSignMessage/PPC64LEandMlDsaVerifyMessageCached/PPC64LEnow also registervg_mldsa*_{sign,verify}_message_prepared. They use the message functions' existing code, which callsvg_mldsa*_{sign,verify}_prepared.μentries share one kernel per parameter set,vg_mldsa*_sign_with_cacheandvg_mldsa*_verify_with_cache. These are internal functions, checked against the untrusted contracts already inProof/MlDsa/PreparedKeyContract.lean.r14/r15, saved in frames.ŝ₁,ŝ₂andt̂₀from it instead of decoding them, and verification copiesNTT(t₁·2ᵈ)for each row.CPre = SPre ∧ SCache). Its contents survive until decoding byExec.frameAny.VCgains a field that the existing keep lemmas maintain, so it covers the cache polynomials through to each row.relct_frameN, byExec.widenand determinism). Every new loop is checked withtaint_decide.pr : Bool: key length, callee contract, and the prepared-key precondition, which the body's frame keeps).PreparedKey.secret_mem,public_mem).mldsa44.sgoes from 4,714 to 2,330 lines.TCB/,Spec/orProof/Framework/changes. There's nosorry,native_decideorbv_decide, and no resource-limit option.Rust
src/mldsa_common.rs: the prepared key types now store and use the prepared key onall(target_arch = "powerpc64", target_endian = "little")as well, sharing the single-implementationprepareblocks of AArch64, ARM, x86 and RISC-V. TheBackendmatches stay exhaustive: PPC64LE has onlyBackend::Scalar. Its baseline functions carry no*_FEATURESconstants, soREQUIREDstays empty there. With this PR, every architecture the module compiles for has prepared keys.Performance (PPC64LE)
Scoped Benchmarks run (
arches=powerpc64,modules=mldsa, against main9ff6f96c). It's one interleaved pass per side, so the numbers are indicative. The rebases since then changed no PPC64LE code.Prepared vs ordinary, both on this branch:
sign_mu, verify,verify_muandpublic_key. Hedgedsignvaries more, because its randomness changes how many times the rejection loop runs.verifymeasured 545.8 µs againstverify_mu's 360.6 µs, though both do the same work, andkeygenmoves 23% between the two sides with no change to its code. I haven't rerun it to get better numbers.mldsa*_prepare/verifying: 32 / 46 / 60 ns on main, 18.6 / 27.9 / 37.3 µs here. On main,prepareon PPC64LE only wraps the key; now it decodes and transforms it. That's the one-time cost of the feature, and it pays for itself after one or two verifications.prepare/signingtimes keygen plus preparation together, so it grows by about 56 / 84 / 126 µs for the same reason.Validation
lake buildpasses, andEmit.lean --checkis clean, its axiom, compiled-code and spec-origin audits included.qemu-ppc64le: all 24 ML-DSA integration tests pass, including ACVPpreparedand Wycheproofsign_seed_prepared/verify_prepared, with detected features and withVG_CPU_FEATURES=none. They also pass natively on x86-64.cargo clippy --all-targets -D warningsis clean natively and forpowerpc64le-unknown-linux-gnu, andcargo fmt --checkis clean.mainis identical.🤖 Generated with Claude Code
https://claude.ai/code/session_015ajQWuKibVLbRQDRNZ3SgM