Skip to content

clazel-p384: group law, scalar product and verify, proven against the contract (3.5h, PR3), tier 0 - #25

Merged
atiernan merged 3 commits into
phase3/p384-fieldfrom
phase3/p384-verify
Oct 27, 2026
Merged

atiernan merged 3 commits into
phase3/p384-fieldfrom
phase3/p384-verify

Conversation

@atiernan

Copy link
Copy Markdown
Member

PR3 of P-384 ECDSA verification (3.5h). It adds the group law, the scalar product and verify, proven against contract.rs over PR2's six axioms. It is stacked on #23, and the crate stays at tier 0.

Commits

  • cb00c2d (contracts): src/point_contract.rs, committed before the code. It states ec_add, scalar_mul, decode_public_key and derive_e (mod n) against spec.rs. verify keeps PR1's verify_requires/verify_ensures unchanged.
  • f2b4401 (code):
    • point.rs: the SEC 1 §2.2.1 affine group law in the spec's case order, plus key decoding and validation.
    • scalar.rs: MSB-first double-and-add. Its invariant is that, after each prefix of bits, the result equals spec::scalar_mul of that prefix. No associativity is used.
    • convert.rs: reduction of an octet prefix mod m.
    • lemmas.rs: among others, the spec's bit-string derive_e equals os2ip of the first min(|h|, 48) octets.
    • verify.rs: proven to give exactly spec::ecdsa_verify(p384(), …) on every input.
  • f6a97f1 (tests): tests/verify.rs.
    • Wycheproof ecdsa_secp384r1_sha384_test.json at d17cc89f: valid tcIds 1, 2, 5, 7, 295, 296, 297 and 300 are accepted; invalid tcIds 102, 109, 151, 171, 195 and 204 are rejected.
    • Also rejected: tampered r and s; r or s equal to 0, n, n + 1 or 2^384 − 1; wrong, short, long and empty digests; off-curve, compressed, infinity, wrong-length and X = p / Y = p keys.
    • A 64-octet digest is truncated to its leftmost 48 octets.

Checked

  • Verus: 133 verified, 0 errors, from a clean cache, re-run independently of the agent. No rlimit is raised.
  • axioms.rs: byte-identical to the reviewed file (SHA-256 e9ee88f1…a4e3). The 18 documented axioms are unchanged.
  • Unchanged: spec.rs and field/contract.rs are untouched. contract.rs changed only in a doc comment.
  • Tests: cargo test passes 7 field tests and 9 verify tests, in both debug and release.
  • Lints: clippy and fmt are clean.
  • cargo xtask check: passes.
  • cargo xtask mutate clazel-p384: 26 of 26 mutations killed with certificates.
  • Speed: about 45 ms per verification in release and 0.94 s in debug, measured on macOS. That fits the design's Stage 1 estimate.

Not done

  • Step 9 with x_R ≥ n is proven but never exercised: no test vector reaches it, and the chance of one doing so is about 2^-190.
  • No mutations of the exec code, no Kani harnesses, no full conformance suite (that is PR5), and no independent transcription (PR6).
  • Verus has been run on macOS only.

CI has not run yet.

🤖 Generated with Claude Code

atiernan and others added 3 commits October 27, 2026 12:38
The statements of the executable group law, scalar product, key decoding,
digest reduction and verify, over the vocabulary of spec.rs. No code yet.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…spec

Affine SEC 1 2.2.1 ec_add in the spec's case order, uncompressed key
decoding, MSB-first double-and-add against spec::scalar_mul, derive_e with
the reduction mod n, and verify meeting verify_ensures, all over the six
fiat axioms and no new one. Adds Fe::dup (a copy with the same which/val).
Tier stays 0.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Eight valid and six invalid vectors of ecdsa_secp384r1_sha384_test.json
(d17cc89f), plus damaged r, s, digests and keys.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@atiernan
atiernan marked this pull request as ready for review October 27, 2026 15:11
@atiernan
atiernan added this pull request to stack #26 October 27, 2026 15:57
@atiernan
atiernan merged commit 7ceed35 into phase3/tls-handover Oct 27, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant