Repository navigation
ARMv7 P-384: [k]G by the shared signed seven-bit comb (sign 5.9×, public key 8×, verify 1.8× faster) - #3742
Merged
Conversation
As for P-256: signing, public-key derivation and verification's [u]G on ARMv7 now use the fixed-base comb secp256k1 uses (Impl/Weierstrass/Arm/ TComb.lean) in place of vg_p384_mul's 384-bit ladder, with P-384's seven-bit tables (Impl/P384/CombTable7.lean): 55 complete additions, each from a masked scan of the 64 entries of a public row of the 337920-byte table VG_P384_COMB. [v]Q in verification stays a call of vg_p384_mul, and verification's generator first expands u, in K's slot, into the table of bits the comb reads. The proofs mirror P-256's; Proof/Ecdsa/Arm/P384/Verified gains wf₀_pre and agree₀. The comb's configuration and the generator lemmas evaluate 2^384, above Lean's default exponentiation threshold, so they raise it to 512, as other P-384 proofs do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWwM9UqiWhzCYtKaWa8
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWwM9UqiWhzCYtKaWa8
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.
This is the P-384 counterpart of #3741 (P-256). It is independent of that PR, and both branch from
main.On ARMv7, P-384 signing, public-key derivation and verification's
[u]Gmultiplied the generator withvg_p384_mul, a double-and-add ladder over all 384 bits. Onmain, signing took 7.97 ms (OpenSSL: 2.76 ms; aws-lc-rs: 638 µs) and key derivation took 7.57 ms (OpenSSL: 2.60 ms) (run).This PR switches them to the fixed-base comb secp256k1 uses on ARMv7 (
Impl/Weierstrass/Arm/TComb.lean), with P-384's verified seven-bit tables (Impl/P384/CombTable7.lean). The comb does 55 complete Renes–Costello–Batina additions, and each one takes its entry from a masked scan of all 64 entries in a public row of the 337,920-byte tableVG_P384_COMB. Verification's[v]Qis still a call ofvg_p384_mul.As for P-256, verification copies
uas words intoK's slot forvg_p384_mul. So its generator (verifyGeneratorP384) first expands that slot into the table of bits the comb reads.Proofs
These mirror #3741's, in P-384's sub-namespaces:
Proof/P384/Arm/Comb.lean: layout,Configand the satisfiable memory.Proof/Ecdsa/Arm/P384/CombGenerator.lean: the generator lemmas.Proof/{Ecdsa,EcKey,Ecdsa/Verify}/Arm/P384/Comb.lean: each function's contract with its table, constant time andVerified.Proof/Ecdsa/Rfc6979/Arm/P384Sha384Comb.lean: the RFC 6979 signer.Proof/Ecdsa/Arm/P384/Verified.leangainswf₀_preandagree₀.sign_ctkeeps its statement.The comb's
Configand the generator lemmas unify terms containing2^384, which is above Lean's default exponentiation threshold. They raise it to 512, as other P-384 proofs do (e.g.Proof/Weierstrass/AArch64/MontFn384.lean).There are no changes to
TCB/orSpec/. The only Rust changes are the regeneratedsrc/asm/arm/{ec_p384,ecdsa_p384}.rsand the newsrc/asm/arm/consts/vg_p384_comb.rs.P-224 and P-521 cannot follow yet. P-224's 37-row table covers 256-bit scalars, but its ladder covers 224 bits, so the comb's
startBitscondition fails. P-521 has nine words, and the comb'sLayoutallows at most six. Each would need a new table or a wider layout.Speed
Benchmarks run on ARMv7, comparing against
main(run):ec_p384_public_key/97ecdh_p384/48ecdsa_p384_sha384_sign/64ecdsa_p384_sha384_sign/16384ecdsa_p384_sha384_verify/64Checks run locally
lake buildandEmit.lean --check.check_lean_imports,check_lean_modules,check_lean_single_importer,check_lean_public_imports(on the changed modules),check_registrations,check_lean_speed,check_variants,check_arch_gatesandcheck_vectors;cargo fmt --check; andcargo clippy --target armv7-unknown-linux-gnueabihf --all-targets -D warnings.cargo test --target armv7-unknown-linux-gnueabihf -- p384under qemu-arm with Wycheproof: 18 tests pass, including RFC 6979 P-384 (keys, public key, SHA-384 signing, verify), CAVP ECDH, Wycheproof ECDSA and ECDH P-384, and compressed points.Generated by Claude Code