Skip to content

AES-GCM x86-64: the out-of-place AVX-512 encryption batches are the in-place ones - #4415

Merged
reaperhulk merged 1 commit into
mainfrom
claude/gcm-enc-z-shared
Nov 7, 2026
Merged

reaperhulk merged 1 commit into
mainfrom
claude/gcm-enc-z-shared

Conversation

@reaperhulk

Copy link
Copy Markdown
Member

Stacked on pyca/verified-garbage#4409 (review only the commit after it). This is the 512-bit counterpart of pyca/verified-garbage#4391. Both out-of-place AVX-512 encryption loops had their own copy of the batch:

  • StitchZTo (keys loaded each round), with xorDataZTo.
  • StitchZHTo (cached keys).

Their proofs were also copies (StitchZTo/Base.lean's XOR lemmas, and batchTo_ok in StitchZTo/Aes.lean and Cached/AesTo.lean). They now use their in-place loops' batches and the proofs of those.

Code.

  • StitchZ.xorDataZM (moved from StitchZH) takes the load mode ld. It reads at Stitch.srcK ld, which is rdx + r8 out of place, as Stitch.xorDataKM does.
  • StitchZ.batch and StitchZH.batch take ix and ld (both default false).
  • StitchZTo.batchTo and StitchZHTo.batchTo are those batches with ld. StitchZTo.xorDataZTo is gone.

The emitted code is unchanged (Emit.lean --check). StitchZ.batch emits exactly the instructions VaesZ.xorDataZ did.

Proofs.

  • StitchZ/Aes.lean:
    • xor1ZM_ok and xorDataZM_ok (moved from Cached/Aes.lean) take the load mode.
    • batchM_ok is the generic batch of the uncached loops, with the code's modes st and ld and rdx at Stitch.wp ld, as AES-GCM x86-64: the out-of-place VAES encryption batch is the in-place one #4391's 256-bit batchM_ok. batch_ok is its in-place case.
    • AInvM drops r8, whose sign depends on the mode. The distance is a hypothesis of the batches and a field of the decryption invariants (DInvM.r8, DInv3M.r8).
  • Cached/Aes.lean: the cached batchM_ok takes st and ld likewise. Cached/Keep.lean's batch_keeps takes both modes.
  • StitchZTo/Aes.lean and Cached/AesTo.lean: batchTo_ok is the generic batch with ld, through AInvTo.toM and AInvM.toTo. Its statement is unchanged, so the out-of-place loop proofs above it are unchanged.
  • StitchZTo/Base.lean: xor1ZTo_ok and xorDataZTo_ok are removed.
  • The users of AInvM.r8 (Cached/Loop.lean, Cached/Loop48.lean, StitchZ/Loop48.lean and Cached/DecFrom.lean) take it from the invariants instead.

Net, the proofs lose 187 lines. What remains duplicated is the out-of-place AVX-512 encryption loops' bodies (StitchZTo/Loop.lean, Loop48.lean, Cached/LoopTo.lean, Loop48To.lean), which #4409 did for the 256-bit loop.

Trust. No Spec/ or TCB/ changes, and no change to the emitted code, so there are no Rust, test or benchmark changes.


Generated by Claude Code

@github-actions github-actions Bot added the untrusted-only This changes exclusively implementations and proofs, and thus is entirely formally verified. label Nov 7, 2026
@reaperhulk
reaperhulk added this pull request to stack #4420 November 7, 2026 09:41
@reaperhulk
reaperhulk enabled stacked auto-merge November 7, 2026 09:42
@reaperhulk
reaperhulk 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 invalid changes in the merge commit Nov 7, 2026
Base automatically changed from claude/gcm-enc-body-shared to main November 7, 2026 10:08
…n-place ones

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ajQWvqXkQxFyWZxghqxBG
@reaperhulk
reaperhulk force-pushed the claude/gcm-enc-z-shared branch from d9fa773 to 4771d58 Compare November 7, 2026 10:08
@reaperhulk
reaperhulk added this pull request to the merge queue Nov 7, 2026
Merged via the queue into main with commit 18cb03d Nov 7, 2026
14 checks passed
@reaperhulk
reaperhulk deleted the claude/gcm-enc-z-shared branch November 7, 2026 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

untrusted-only This changes exclusively implementations and proofs, and thus is entirely formally verified.

Development

Successfully merging this pull request may close these issues.

2 participants