Skip to content

GCM: 48 prepared powers on SSE registers (vg_aes_gcm_prepare_pclmul) - #4521

Merged
alex merged 9 commits into
mainfrom
claude/gcm-prepare-pclmul
Nov 7, 2026
Merged

alex merged 9 commits into
mainfrom
claude/gcm-prepare-pclmul

Conversation

@alex

@alex alex commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Implementation PR, based on main. No TCB/ or Spec/ change.

vg_aes_gcm_prepare for CPUs with PCLMULQDQ and SSSE3 but not AVX. It is part of moving AES-GCM onto one key layout per target, where every x86-64 backend takes the 1 KiB prepared context. It joins _vpclmul_avx512, _vpclmul (#4518) and _pclmul_avx (#4520).

  • Impl/Gcm/X86_64/PrepareAvx.lean: prepareSse is setupS ++ plan48.flatMap stepS, the SSE code that GCM: 48 prepared powers on 128-bit registers (vg_aes_gcm_prepare_pclmul_avx) #4520's prepare is proven on through WP.lane0. The SSE code (sqS, mulDS, stepS, setupS) moves here from Proof/Gcm/X86_64/PrepareAvx/{Step,Ok}.lean, since Impl/ may not import Proof/. The proofs now open it from Impl.
  • Proof/Gcm/X86_64/PrepareAvx/Ok.lean: prepareSse_ok comes straight from setupS_ok and planS_ok (no lane projection), then Prepare.verified_of.
  • Proof/Gcm/X86_64/PrepareCT.lean: prepareSse_ct, by taint_decide.
  • Artifacts/Gcm/X86_64.lean: vg_aes_gcm_prepare_pclmul, features pclmulqdq and ssse3, as the SSE GHASH (GhashImpls).

Nothing in Rust calls it yet. The Rust GCM rework that calls vg_aes_gcm_prepare_auto follows separately, with a Benchmarks run of key setup.

Checks:

  • the modules build;
  • Emit.lean --check is clean on main daf7be3;
  • check_lean_public_imports.py, every Static checks step and cargo clippy --all-targets -- -D warnings pass;
  • CI is all green.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TKUFHHDjuK1puxAcLZKKff

…ul_avx)

PrepareAvx.prepare runs the first three rounds of prepare16's plan
(H'^2-H'^8), puts H'^9-H'^16 into eight registers keeping H'^8, and
multiplies them by H'^8 four times, eight independent products a round,
storing each power: vg_aes_gcm_prepare for CPUs with AVX and PCLMULQDQ.
The plan's proof is generalized over the largest power computed (16 or
48); the new function is proven against prepareContract, and constant
time by taint_decide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHHDjuK1puxAcLZKKff
PrepareAvx.prepareSse is the SSE code that PrepareAvx.prepare is proven
on: vg_aes_gcm_prepare for CPUs with PCLMULQDQ and SSSE3 but not AVX,
proven directly (planS_ok) against prepareContract, and constant time by
taint_decide. The SSE code (sqS, mulDS, stepS, setupS) moves from Proof/
to Impl/, which may not import Proof/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHHDjuK1puxAcLZKKff

alex commented Nov 7, 2026

Copy link
Copy Markdown
Member Author

Static checks fails only at ci/check_variants.py, with the failure this PR's description expects: "the variant vg_aes_gcm_prepare_pclmul_avx is neither called by another generated function nor used by the Rust code". The check is right, and nothing in this PR alone can fix it. Once vg_aes_gcm_prepare_pclmul exists, _pclmul_avx counts as its variant. Only the Rust GCM rework that calls vg_aes_gcm_prepare_auto uses it, and that dispatcher needs the baseline x86-64 prepare first. Not re-running: the failure is deterministic. This PR stays a draft until it can go in with that change.


Generated by Claude Code

Base automatically changed from claude/gcm-prepare-pclmul-avx-2 to main November 7, 2026 19:48
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

This pull request has conflicts with main, found after cbb0090 landed on main: rebase it to resolve them. Before rebasing, see CLAUDE.md on checking how much Lean main changed, and on restacking a stacked pull request.

Posted by .github/workflows/conflicts.yml, once per push to a conflicting pull request.

Restack onto main after #4520's squash: main's files with this PR's
commit re-applied.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHHDjuK1puxAcLZKKff
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHHDjuK1puxAcLZKKff
@alex

alex commented Nov 7, 2026

Copy link
Copy Markdown
Member Author

what is this waiting on?

alex commented Nov 7, 2026 •

Copy link
Copy Markdown
Member Author

Correction: this no longer waits on anything. ci/check_variants.py, the only check that failed here, was removed in #4549. I've merged main into this branch and am re-checking the generated crates. Once CI is green I'll mark it ready to land on its own. The same goes for #4538.

The Rust rework that calls vg_aes_gcm_prepare_auto (and the _prepared_auto / _with_powers_auto functions) will follow separately on main, with a Benchmarks run of key setup.

What I wrote before: that this waited on the Rust change calling vg_aes_gcm_prepare_auto, because check_variants.py rejected vg_aes_gcm_prepare_pclmul_avx until something called it.


Generated by Claude Code

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 22:18
@alex
alex added this pull request to the merge queue Nov 7, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 7, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHHDjuK1puxAcLZKKff
With #4538's baseline vg_aes_gcm_prepare on main, the dispatcher also
tries vg_aes_gcm_prepare_pclmul, after _pclmul_avx and before the
baseline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHHDjuK1puxAcLZKKff
@alex
alex enabled auto-merge November 7, 2026 22:44
@alex
alex added this pull request to the merge queue Nov 7, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 7, 2026

alex commented Nov 7, 2026

Copy link
Copy Markdown
Member Author

The merge queue dropped this on Rust coverage (run 42422726425). The check was "An architecture's tests leave lines it builds uncovered", and the uncovered line is crates/verified-garbage-asm-x86_64/src/dispatch/rsa_pkcs1_enc.rs:46.

I don't think that failure is this PR's:

  • This PR touches only GCM: its x86-64 crate diff is gcm.rs, gcm.s and dispatch/gcm.rs.
  • That line is vg_rsa_pkcs1_decrypt_auto's _sha256_shani_crt_adx branch, taken only on a CPU with SHA-NI and ADX but without AVX-512 IFMA. No VG_CPU_FEATURES group seems to pin that combination, so whether it's covered depends on the hardware the native x86-64 runner lands on.
  • The queue runs just before and after this one passed Rust coverage. One is Arm: vg_aes_gcm_open_to in one pass, sharing open's body #4561's (8549e30), built on top of this PR's queue commit.

I have no fix to port into this PR: it belongs in ci/cpu_tests.py's groups, or in the RSA tests. Re-queueing should pass on a run whose runner covers that line. I can't re-queue it myself.


Generated by Claude Code

@alex
alex added this pull request to the merge queue Nov 7, 2026
Merged via the queue into main with commit 96834d5 Nov 7, 2026
32 checks passed
@alex
alex deleted the claude/gcm-prepare-pclmul branch November 7, 2026 23:23
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