Skip to content

PPC64LE: vg_chacha20_poly1305_open_to sharing open's body, and decrypt on PPC64LE - #4427

Merged
reaperhulk merged 2 commits into
mainfrom
claude/determined-gates-p7sa7b-ppc64le-open-to
Nov 7, 2026
Merged

reaperhulk merged 2 commits into
mainfrom
claude/determined-gates-p7sa7b-ppc64le-open-to

Conversation

@reaperhulk

Copy link
Copy Markdown
Member

This PR is stacked on #4424, the PPC64LE src/dst ChaCha20 kernel. It is the PPC64LE counterpart of #4384: out-of-place ChaCha20-Poly1305 decryption without a copy. No change to TCB/ or Spec/.

Design: one body for open and open_to

The decryption code exists once; open and open_to differ only in a short entry block.

  • Shared body. The body reads the source at r7 and writes the destination it finds in r11 at entry. moves keeps the destination in r31.
    • r31 is nonvolatile and saved in the context, and no callee touches it, so the taint analysis keeps it public across the calls.
    • r30 was ruled out because vg_chacha20_xor reloads it from memory.
  • Calls. crypt passes r7 := r31 to the kernel, from source to destination. zeroData zeroes from r31.
  • Saved registers. r24–r29 and r31, plus LR at savOff + 56. The working space grows from 81 to 82 doublewords (656 bytes).
  • In place. seal and open run the body after inPlace, which is mr r11, r7. Their frames stay at 688 bytes, and the stack at 848. seal_gather's sealCode changes the same way.
  • Out of place. vg_chacha20_poly1305_open_to runs the body after toEntry. toEntry takes dst from r9, and tag and work from the stack arguments withStackScratchArgs lays out at r1+96 and r1+104. Its frame is withStackScratchArgsWiped 768 1 82, and its stack is 928.

Proofs

  • Correctness. APre now takes membership facts, with op/oR and alias. Inv.frame is over the context, the destination and the stack below. crypt_ok goes through the kernel's xor_call_to. zeroData_ok, body_ok and open_correct are stated at the destination (CorePost).
  • Constant time. open_rel is one relational proof of the body, which both entries use: open_ct/seal_ct on the inPlace code, and openTo_ct after toEntry.
  • open_to.
    • toEntry_ok, apre_openTo and openTo_ok cover the entry and its correctness.
    • openTo_verified is the bridge to openToScratchContract PPC64LE.abi 82 160.
    • openTo_framed gives the frame.
  • Wiped frame. New Proof/Framework/PPC64LE/StackScratchArgsWipe.lean, PPC64LE's counterpart of RISC-V's: wipeFrom_run and Verified.stackScratchArgsWiped, whose hpostOut may assume the precondition. wipeFrom and withStackScratchArgsWiped are added in Impl/StackScratch/PPC64LE/Args.lean.

Rust

ChaCha20Poly1305::decrypt, its unit test decrypt_out_of_place, the Wycheproof out-of-place check and the benchmark group are now enabled on little-endian PPC64 as well as RISC-V.

Checks

  • Full lake build passes, and Emit.lean passes along with Emit.lean --check; the emitter changed only crates/verified-garbage-asm-powerpc64le ChaCha20-Poly1305.
  • check_lean_public_imports.py passes, and the static checks pass.
  • Under qemu, cargo test --target powerpc64le-unknown-linux-gnu passes with Wycheproof (676 tests), including decrypt_out_of_place.
  • Host cargo fmt --check and clippy pass, as does clippy for PPC64LE on the library.
  • Not run here: the bench crate does not cross-compile for PPC64LE here because of openssl-sys. CI's lint job covers it.

Benchmarks: not run. seal/open gain one mr and one more saved register each, plus a word to wipe. A scoped manual Benchmarks run (ChaCha20-Poly1305, PPC64LE) should go with this PR; I have not triggered one.


Generated by Claude Code

Base automatically changed from claude/determined-gates-p7sa7b-ppc64le-xor to main November 7, 2026 10:19
@reaperhulk
reaperhulk force-pushed the claude/determined-gates-p7sa7b-ppc64le-open-to branch from b6e372e to 47c1ad4 Compare November 7, 2026 10:19
@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 a conflict with the base branch Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

This pull request has conflicts with main, found after 7bb58de 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.

…t on PPC64LE

As on RISC-V (#4384): one body serves open and open_to. It reads the
source at r7 and writes the destination it finds in r11 at entry, kept in
r31 (nonvolatile, saved in the context, which no callee touches, so the
taint analysis keeps it public across the calls); the working space grows
from 81 to 82 doublewords. seal and open run it in place (inPlace,
r11 = r7); open_to enters through toEntry, which takes dst from r9, and
tag and work from its stack arguments.

The proofs are open's, with the destination equal to or apart from the
source (APre.alias), and one relational constant-time proof of the body
(open_rel) that both entries use. open_to's working space is wiped after
the code: Verified.stackScratchArgsWiped (Proof/Framework/PPC64LE/
StackScratchArgsWipe.lean), PPC64LE's counterpart of RISC-V's.

ChaCha20Poly1305::decrypt, its tests and its benchmark now also on
little-endian PPC64.

No change to TCB/ or Spec/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ajQWwrECv53ESEcwjcHaU
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ajQWwrECv53ESEcwjcHaU
@reaperhulk
reaperhulk force-pushed the claude/determined-gates-p7sa7b-ppc64le-open-to branch from 47c1ad4 to c82b628 Compare November 7, 2026 10:46
@reaperhulk
reaperhulk added this pull request to the merge queue Nov 7, 2026
Merged via the queue into main with commit 1b3c5d3 Nov 7, 2026
35 checks passed
@reaperhulk
reaperhulk deleted the claude/determined-gates-p7sa7b-ppc64le-open-to branch November 7, 2026 11:41
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