Repository navigation
AES-GCM x86-64: the out-of-place VAES encryption batch is the in-place one - #4391
Merged
Merged
Conversation
… (WIP) Stitch.batch takes the load mode (ld: the data read at rdx + r8); StitchTo's batch, its XOR and their proofs are replaced by Stitch.batchM_ok. The distance in r8 moves from AInvM to the loops' invariants. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWvqXkQxFyWZxghqxBG
This was referenced Nov 7, 2026
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.
Stacked on pyca/verified-garbage#4390 (review only the commit after it). This is the encryption counterpart of pyca/verified-garbage#4388. The 256-bit out-of-place encryption loop (
StitchTo) had its own copy of the batch:xorDataKToandbatchTo, with their own 220 lines of proof. It now usesStitch.batchand its proof.Code.
Stitch.batchtakes a second mode,ld(defaultfalse). It reads each pair of data blocks atrdx + r8 + 32 jinstead of atrdx + 32 j(Stitch.srcK). Out-of-place encryption reads the plaintext there and writes the ciphertext atrdx, where the GHASH loads read it back, as in place.Stitch.firstandStitch.bodypassldon.StitchTo.firstToandbodyToare nowStitch.first trueandStitch.body true, andStitchTo.xorDataKToandbatchToare gone. The emitted code is unchanged (Emit.lean --check).Proofs.
Stitch/Aes.lean:xor1M_okandxorDataKM_oktake the load mode: they read atoA s ld, which isrdx, orrdx + r8.batchM_oktakes the code's two modes,st(store atrdx + r8) andld, withst = ix && !ldandld → ix, whereixsays whether the output is the data or the buffer atr10.rdxpoints at the data, or, whenld, at the output.r8is now a hypothesis ofbatchM_ok, and a field of the loops' invariants (DInvM.r8,StitchFrom.ReadyFrom.r8), instead of a field ofAInvM, because its sign depends on the mode.StitchTo/Aes.lean:batchTo_okisbatchM_okwithld, throughAInvTo.toMandAInvM.toTo. Its statement is unchanged, soStitchTo/Loop.lean,StitchR/OnePass.leanandStitchR/RemETo.leanare unchanged.StitchTo/Base.lean:xor1KTo_okandxorDataKTo_okare removed.Net, the proofs lose 177 lines.
Not yet shared, for follow-ups: the out-of-place loop's body, first group and final group (
StitchTo.bodyTo_ok,firstTo_okandfinalTo_ok). They reuse the in-place GHASH lemmas through the in-place viewStitchZTo.dst, but are still separate fromStitch.body_okand its neighbours. The same applies to the 512-bit out-of-place encryption loops (StitchZTo,StitchZHTo).Trust. No
Spec/orTCB/changes, and no change to the emitted code, so there are no Rust, test or benchmark changes.Generated by Claude Code