Repository navigation
PPC64LE Montgomery multiplication of up to four words: q = t₀ when m' = 1 - #4789
Merged
Merged
Conversation
…' = 1 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHH4GefHP3pmPRSL4N4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHH4GefHP3pmPRSL4N4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHH4GefHP3pmPRSL4N4
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 (PPC64LE audit, finding 1). This follows #4783.
Each row of
rmul4's reduction computesq = t₀ m' mod 2⁶⁴. It loadsm'from the working space and multiplies, which puts a load and a multiply on the row's loop-carried path. For a modulus withm' = 1(m ≡ -1 mod 2⁶⁴: P-256's and P-192'sp),qist₀itself.Impl/Mont/PPC64LE.lean:qhead Misori r9, t₀, 0whenM.minv.toNat = 1, and the load andmulldotherwise.qrowMstarts with it. The choice is made inside the block, so the code's shape does not change.Proof/Mont/PPC64LE/Ops.lean:qhead_okgives either branch asr9 = t₀ · mp mod 2⁶⁴for somempwithm · mp ≡ -1.qrowM_oknow starts fromqhead_ok, and the rest of its proof is unchanged.QPregainsone:m' = 1means the word at[M.tmp]is 1.rmul4_okalready knows that word isM.minv.vg_p256_mul_mod_pandvg_p192_mul_mod_p: in each, oneldand onemulldbecome oneori.No TCB or Spec change. The statements of
rmul4_okandmulFn_okare unchanged.Testing
lake buildandEmit.leanpass, as doesEmit.lean --check(run before the rebase onto7bb62d40).check_lean_public_imports.pypass.Benchmark
POWER9, run 42540441353, scoped to
arches=powerpc64, base7bb62d40:ec_p256_public_key/65ecdh_p192/24ecdh_p256/32ecdsa_p256_sha256_sign/64ecdsa_p256_sha256_sign/1024ecdsa_p256_sha256_sign/16384ecdsa_p256_sha256_verify/64ecdsa_p256_sha256_verify/1024ecdsa_p256_sha256_verify/16384ecdsa_p256_sha384_sign/64ecdsa_p256_sha384_sign/1024ecdsa_p256_sha384_sign/16384ecdsa_p256_sha384_verify/64ecdsa_p256_sha384_verify/1024ecdsa_p256_sha384_verify/16384The one slower row,
sha256_sign/64, looks like noise. Every other signing row is faster, including the same signature over SHA-384, and the change only removes instructions from the multiplication.Generated by Claude Code