Skip to content

GCM: 48 prepared powers on 256-bit registers (vg_aes_gcm_prepare_vpclmul) - #4518

Merged
alex merged 2 commits into
mainfrom
claude/gcm-prepare-vpclmul-2
Nov 7, 2026
Merged

alex merged 2 commits into
mainfrom
claude/gcm-prepare-vpclmul-2

Conversation

@alex

@alex alex commented Nov 7, 2026

Copy link
Copy Markdown
Member

Implementation PR (Impl + Proof + registration + regenerated crate). No TCB/ or Spec/ change.

Part of moving AES-GCM onto one key layout per target, so that the generated dispatchers make the only choice. On x86-64 every backend will take the 1 KiB prepared context, which vg_aes_gcm_prepare writes. Today only the AVX-512 code (_vpclmul_avx512) has a prepare. This adds one for CPUs with VPCLMULQDQ and AVX2 but not AVX-512.

  • Impl/Gcm/X86_64/Prepare16.lean: prepare runs prepare16's plan (pairs 0–7), squares H'⁸ to H'¹⁶ in both lanes, and multiplies the eight pairs the registers hold by it twice, storing pairs 8–15, then 16–23. That is 17 more 256-bit steps than prepare16, each multiplication of a round independent of the others.
  • Proof/Gcm/X86_64/Prepare16.lean: the plan's checker (valid) and invariant (Inv) now take the number of pairs stored (8 for prepare16, 24 for prepare). prepare_ok gives Prepare.PrepOk, and Prepare.verified_of gives prepareContract.
  • Proof/Gcm/X86_64/PrepareCT.lean: prepare_ct, by taint_decide.
  • Artifacts/Gcm/X86_64.lean: vg_aes_gcm_prepare_vpclmul, with the features of prepare16_vpclmul.

No Rust calls the new function yet. The Rust change that does (the GCM dispatch rework) will come with a Benchmarks run of key setup. The coordinating session agreed to measure it there rather than add a temporary call here.

Checks: the module builds, Emit.lean regenerates the crates with no diff, every Static checks step and check_lean_public_imports.py pass, and so does cargo clippy --all-targets -- -D warnings.


Generated by Claude Code

…mul)

Prepare16.prepare runs prepare16's plan, squares H'^8 to H'^16 in both
lanes, and multiplies the eight pairs the registers hold by it twice,
storing pairs 8-15 and 16-23: vg_aes_gcm_prepare for CPUs with VPCLMULQDQ
and AVX2 but not AVX-512. The plan's proof is generalized over the number
of pairs stored; the new function is proven against prepareContract, and
constant time by taint_decide. The generated crates follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHHDjuK1puxAcLZKKff
@alex
alex marked this pull request as ready for review November 7, 2026 19:01
@alex
alex added this pull request to the merge queue Nov 7, 2026
Merged via the queue into main with commit 079a361 Nov 7, 2026
32 checks passed
@alex
alex deleted the claude/gcm-prepare-vpclmul-2 branch November 7, 2026 19:10
alex pushed a commit that referenced this pull request Nov 7, 2026
Resolve the conflicts with #4518 by keeping both registrations and both
constant-time theorems, and regenerate the x86-64 crate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHHDjuK1puxAcLZKKff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants