Skip to content

TCB: a mode a contract may make public (Abi.mode, Abi.withMode) - #4326

Closed
reaperhulk wants to merge 1 commit into
claude/dit-tokenfrom
claude/dit-mode
Closed

reaperhulk wants to merge 1 commit into
claude/dit-tokenfrom
claude/dit-mode

Conversation

@reaperhulk

@reaperhulk reaperhulk commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Trust change (TCB). This is the TCB half of letting vg_dit_enter skip writing PSTATE.DIT when it is already on. The Spec change (#4327) and the implementation (#4328) are stacked on it. It is stacked on #4210.

What changes in TCB/

  • Abi.mode (TCB/Sig.lean): the mode the code runs in, as a number. On AArch64 it is PSTATE.DIT, 1 or 0 (TCB/AArch64/Target.lean). It defaults to 0 on every other target.
  • Abi.withMode (TCB/Sig.lean):
    • A.withMode true is A with pub strengthened to A.pub s₁ s₂ ∧ A.mode s₁ = A.mode s₂.
    • A.withMode false is A.
  • Api.pubMode and Artifact.pubMode (TCB/Artifact.lean), both false by default. Artifact.ofSig now states the contract under ….withMode pubMode. Registration and Api.artifact (TCB/Registration.lean) pass pubMode from the Api.
  • Docs for PSTATE.DIT in TCB/AArch64/Isa.lean.

Why it is sound

Making the mode public only narrows which pairs of runs a contract compares: both runs have DIT on, or both have it off. That is correct because the Rust code (src/dit.rs) turns DIT on for an operation whatever data it is given, so whether DIT is on depends on nothing secret.

What it leaves alone

  • Every existing contract. pubMode is false by default, and A.withMode false reduces to A, so no existing contract or proof changes meaning. Only Spec/Dit.lean sets it (Spec/Dit: vg_dit_enter's contract makes the mode public #4327).
  • The AArch64 calling convention's pub. I rejected making PSTATE.DIT public there. That would force every proof composing calls (RelCT, Inline) to carry DIT agreement through its taint analysis, across all AArch64 proofs.

Proof-side changes

The four proof structures that restate ofSig for variants now say .withMode api.pubMode:

  • Proof/Sha1/X86/Variants/Interface.lean
  • Proof/Sha256/X86/Variants/Interface.lean
  • Proof/Pbkdf2/Md/{AArch64,X86_64}/Variant.lean

Their instances are unchanged: the default proofs still close them.

Rebased onto main (2026-11-07)

On main, the Artifact structure moved from TCB/Artifact.lean into TCB/Registration.lean. So the Artifact.pubMode field and the .withMode pubMode in Artifact.ofSig are now there, unchanged in content. Api.pubMode stays in TCB/Artifact.lean, in Api. A full lake build and Emit.lean --check at the top of the stack pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_015ajQWwnPmAfvKpXDUq9Tjq

`Abi.mode` is the mode the code runs in, on AArch64 PSTATE.DIT, and
`A.withMode true` is the calling convention with it public. An `Api` says
whether its contracts use it (`pubMode`, false by default), and
`Artifact.ofSig` states it: every other artifact's contract is under
`A.withMode false`, which is `A`. The structures that restate `ofSig` for
variants follow.

The Rust code turns data independent timing on for an operation whatever
its data, so whether it is on depends on nothing secret; a contract that
makes it public lets `vg_dit_enter` skip writing PSTATE.DIT when it is
already on.

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

Copy link
Copy Markdown
Member Author

Replaced by #4483, which carries this change together with the other DIT TCB change, based on main so it can be reviewed and merged on its own. The branch stays, since the DIT stack above it still builds on it.

@reaperhulk reaperhulk closed this Nov 7, 2026
An error occurred while trying to automatically change base from claude/dit-token to main November 8, 2026 16:48
An error occurred while trying to automatically change base from claude/dit-token to main November 8, 2026 16:49
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.

1 participant