Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 54 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ jobs:
# at column 0. This check is text only, so it belongs in this job rather than behind
# a build, and for lakefile.lean, Interop/ and scripts/ it is the only check of any
# kind that reads them for this: Lake elaborates the lakefile from `import Lake` with
# no Mathlib linter registered, the interop job builds only Interop/'s listed bridges
# and does not gate on warnings, and scripts/ is built here but imports no Mathlib, so
# the `weak.` option is dropped.
# no Mathlib linter registered, the Interop sub-project jobs build only the modules
# their lakefiles list and do not gate on warnings, and scripts/ is built here but
# imports no Mathlib, so the `weak.` option is dropped.
- name: Check comment fences
run: |
bash scripts/test-comment-fences.sh
Expand All @@ -99,9 +99,37 @@ jobs:
uv run --no-project --python 3.12 python scripts/test-validation.py
bash scripts/check-imports.sh

interop_subprojects:
name: List Interop Sub-projects
runs-on: ubuntu-latest
outputs:
subprojects: ${{ steps.list.outputs.subprojects }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
with:
version: "0.13.6"
enable-cache: false
# Every directory `Interop/<Sub>/` with a `lakefile.toml` is a sub-project of its own.
- name: List the sub-projects
id: list
run: |
uv run --no-project --python 3.12 python scripts/test-interop-subprojects.py
subprojects="$(uv run --no-project --python 3.12 python scripts/interop-subprojects.py list)"
echo "subprojects=$subprojects" >> "$GITHUB_OUTPUT"

interop:
name: Interop Bridges
name: Interop ${{ matrix.subproject }}
needs: interop_subprojects
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
subproject: ${{ fromJSON(needs.interop_subprojects.outputs.subprojects) }}
defaults:
run:
working-directory: Interop/${{ matrix.subproject }}
env:
CLEAN_BUILD: ${{ github.event_name == 'schedule' || inputs.clean_build == true }}
steps:
Expand All @@ -112,10 +140,11 @@ jobs:
version: "0.13.6"
enable-cache: false
- name: Free unused hosted-runner SDKs
run: bash scripts/free-ci-disk-space.sh
# The same caches as `Build Project`. `Interop/lakefile.toml` shares the root's dependency
# cache (`packagesDir = "../.lake/packages"`) and requires VCVio by path, whose build lands in
# the root's `.lake/build`, so both restore as they are.
run: bash "$GITHUB_WORKSPACE/scripts/free-ci-disk-space.sh"
# The same caches as `Build Project`. A sub-project whose pins equal the root's shares the
# root's dependency cache (`packagesDir = "../../.lake/packages"`), and every sub-project
# requires VCVio by path, whose build lands in the root's `.lake/build`, so both restore as
# they are.
- name: Restore dependency cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
Expand Down Expand Up @@ -145,22 +174,25 @@ jobs:
lint: false
use-github-cache: false
use-mathlib-cache: false
- name: Build the Interop package (hax, Aeneas and the bridges)
working-directory: Interop
lake-package-directory: Interop/${{ matrix.subproject }}
- name: Build the sub-project
run: |
lake exe cache get
lake build
# The modules are `InteropRust`'s roots in `Interop/lakefile.toml`.
- name: Enforce zero axiom and sorry debt in the bridges
working-directory: Interop
run: >-
lake exe axiomsweep --root Interop.Aeneas.ITree --root Interop.Aeneas.WP
--root Interop.Rust.Common --root Interop.Rust.Run --root Interop.Rust.RustM
--root Interop.Rust.Triple --root Interop.Hax.Holds
--root Interop.Hax.Adc.Verification --root Interop.Hax.Barrett.Verification
--root Interop.Hax.CenteredBinomial.Verification --root Interop.Hax.Computation.Verification
--root Interop.Hax.Division.Verification --root Interop.Hax.Examples.Verification
--baseline ../scripts/axiom_baseline.json --check
- name: Run the sub-project's tests
run: |
if lake check-test; then
lake test
else
echo "No test driver in Interop/${{ matrix.subproject }}."
fi
# The roots are those of the default libraries in the sub-project's `lakefile.toml`.
- name: Enforce zero axiom and sorry debt
run: |
roots="$(uv run --no-project --python 3.12 python ../../scripts/interop-subprojects.py roots .)"
args=()
while read -r root; do args+=(--root "$root"); done <<< "$roots"
lake exe axiomsweep "${args[@]}" --baseline ../../scripts/axiom_baseline.json --check

downstream_stub_link:
name: Downstream Consumer Build (no submodules)
Expand Down Expand Up @@ -417,8 +449,7 @@ jobs:
# Zero debt: any taint (exit 1: `sorryAx` or a non-standard axiom) fails the build, as
# do infrastructure failures (exit 2: missing, unparsable or nonempty baseline, tool
# breakage) — a broken tool must never read as a clean verdict.
# Sweeps the non-test libraries; Interop (the declared TCB) is bounded by
# its import-isolation gate instead.
# Sweeps the non-test libraries; each Interop sub-project's job sweeps its own roots.
# Exercise the sweep against its own fixtures before trusting its verdict on the
# library: the fixtures carry synthetic taint of each shape the tool reasons about
# (direct and transitive `sorryAx`, an axiom occurring only in a type, a mutual
Expand Down
37 changes: 19 additions & 18 deletions .github/workflows/hax-extraction.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: hax Extraction

# The Lean modules under `Interop/Hax/<Name>/Extraction/` are extracted by the hax CLI from the Rust
# crates next to them (`scripts/regenerate-hax.sh`) and committed, so building `Interop/` needs no
# Rust. This job reruns the extraction with the `cargo-hax` release that `Interop/lakefile.toml`
# pins and fails if a committed module differs from a fresh extraction.
# The `Interop/Aeneas` sub-project's own check. The Lean modules under
# `Interop/Aeneas/Hax/<Name>/Extraction/` are extracted by the hax CLI from the Rust crates next to
# them (`scripts/regenerate-hax.sh`) and committed, so building the sub-project needs no Rust. This
# job reruns the extraction with the `cargo-hax` release that `Interop/Aeneas/lakefile.toml` pins
# and fails if a committed module differs from a fresh extraction.
#
# It runs when a crate, an extracted module, the workspace manifests, the pin or the script changes,
# and not for edits to the proofs (`Verification.lean`).
Expand All @@ -12,24 +13,24 @@ on:
push:
branches: [main]
paths:
- "Interop/Hax/*/src/**"
- "Interop/Hax/*/Cargo.toml"
- "Interop/Hax/*/hax.toml"
- "Interop/Hax/*/Extraction/**"
- "Interop/Hax/Cargo.toml"
- "Interop/Hax/Cargo.lock"
- "Interop/lakefile.toml"
- "Interop/Aeneas/Hax/*/src/**"
- "Interop/Aeneas/Hax/*/Cargo.toml"
- "Interop/Aeneas/Hax/*/hax.toml"
- "Interop/Aeneas/Hax/*/Extraction/**"
- "Interop/Aeneas/Hax/Cargo.toml"
- "Interop/Aeneas/Hax/Cargo.lock"
- "Interop/Aeneas/lakefile.toml"
- "scripts/regenerate-hax.sh"
- ".github/workflows/hax-extraction.yml"
pull_request:
paths:
- "Interop/Hax/*/src/**"
- "Interop/Hax/*/Cargo.toml"
- "Interop/Hax/*/hax.toml"
- "Interop/Hax/*/Extraction/**"
- "Interop/Hax/Cargo.toml"
- "Interop/Hax/Cargo.lock"
- "Interop/lakefile.toml"
- "Interop/Aeneas/Hax/*/src/**"
- "Interop/Aeneas/Hax/*/Cargo.toml"
- "Interop/Aeneas/Hax/*/hax.toml"
- "Interop/Aeneas/Hax/*/Extraction/**"
- "Interop/Aeneas/Hax/Cargo.toml"
- "Interop/Aeneas/Hax/Cargo.lock"
- "Interop/Aeneas/lakefile.toml"
- "scripts/regenerate-hax.sh"
- ".github/workflows/hax-extraction.yml"
workflow_dispatch:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/interop-isolation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ name: Interop TCB Isolation

# Enforces the contract documented in `Interop/README.md` and
# `docs/agents/interop.md`: core VCVio libraries must not import from
# `Interop.…`, `Hax.…`, or `Aeneas.…`, and `Interop/**` must not depend on
# `Interop.…`, `Hax.…`, or `Aeneas.…`; `Interop/**` must not depend on
# downstream libraries (`LatticeCrypto`, `Examples`, `LatticeCryptoTest`,
# `Extern`, `VCVioTest`).
# `Extern`, `VCVioTest`); and a sub-project `Interop/<A>/` imports another,
# `Interop.<B>.…`, only through `scripts/interop_import_allowlist.txt`.
#
# Runs on every PR and on pushes to `main`. The check is fast
# and parses source with Lean; it does not build the project or fetch Lake dependencies.
Expand Down
27 changes: 17 additions & 10 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ unfold their definitions.
access an unexposed implementation from the same dependency when proving its public API.
- Do not enable `backward.privateInPublic` or `backward.proofsInPublic`; resolve visibility and
proof-metavariable issues directly.
- The `Interop/` package's built bridges follow this policy. The unported hax examples in `Interop/Hax/` are not built and keep their old form until ported.
- The `Interop/` sub-projects follow this policy; the modules hax extracts keep the form the tool
emits.

Section `variable` lines carry an instance assumption only when the theorems in scope share it:
Lean auto-includes an instance-implicit section variable in every theorem mentioning its types,
Expand Down Expand Up @@ -111,7 +112,10 @@ build boundaries and the staged consolidation.
- `LatticeCryptoTest/`: ACVP vectors, executable regression tests, and cross-checks against native backends.
- `VCVioTest/`: framework smoke tests and test support modules.
- `Examples/`: compact framework examples such as OneTimePad, ElGamal, Schnorr, and program-logic tactic walkthroughs; `Examples/Widgets/` holds the proof widgets they display.
- `Interop/`: bridges to external verification tools (hax and Aeneas today), built as their own Lake package so their requires never reach VCVio's dependents. **Strict TCB isolation**: nothing in core VCVio depends on it. See `docs/agents/interop.md`.
- `Interop/`: sub-projects connecting VCVio to code and tools outside Lean, each a directory with
its own Lake package, trusted base and README, so their requires never reach VCVio's dependents;
`Interop/Aeneas` carries Rust code extracted by hax and Aeneas. **Strict TCB isolation**: nothing
in core VCVio depends on it. See `Interop/README.md` and `docs/agents/interop.md`.
- `csrc/`: C FFI shims used for differential testing against native ML-DSA, ML-KEM, and Falcon code.
- `third_party/`: native backends as git submodules; when they are not checked out (fresh clones, Lake dependency checkouts), the native `extern_lib` targets build as empty stub archives.

Expand Down Expand Up @@ -158,14 +162,16 @@ keeps every proof library — and any downstream Lake project requiring VCVio
link-safe when the `third_party/` submodules are absent. Enforced by
`scripts/check-extern-isolation.sh` on every PR.

For `Interop/`, the dependency contract is one-way:
For `Interop/`, each sub-project `Interop/<A>/` is its own Lake package, and the dependency
contract is one-way:

```
Interop/{Hax,Aeneas,Rust}/ → VCVio/, ToMathlib/, (Hax.…), (Aeneas.…)
Interop/<A>/ → VCVio/, ToMathlib/, PolyFun, its own tools (Hax.…, Aeneas.…)
Interop/<A>/ → Interop/<B>/ only through a require listed in scripts/interop_import_allowlist.txt
```

`Interop/**` may **never** be imported from `VCVio/`, `LatticeCrypto/`,
`LatticeCryptoTest/`, `Examples/`, `ToMathlib/`, `Extern/`,
`LatticeCryptoTest/`, `HashSig/`, `HashSigTest/`, `Examples/`, `ToMathlib/`, `Extern/`,
or `VCVioTest/`. This contract is enforced by
`scripts/check-interop-isolation.sh` and the
`Interop TCB Isolation` GitHub workflow on every PR.
Expand Down Expand Up @@ -269,7 +275,7 @@ Security notions, experiments, games, and advantages follow
- Falcon GPV instantiation: `LatticeCrypto/Falcon/Scheme.lean`
- Lattice hardness assumptions: `LatticeCrypto/HardnessAssumptions/LearningWithErrors.lean`, `LatticeCrypto/HardnessAssumptions/ShortIntegerSolution.lean`
- Differential and vector tests: `LatticeCryptoTest/`
- Rust verification interop (hax / aeneas): `Interop/lakefile.toml`, `Interop/Rust/RustM.lean`, `Interop/README.md`, `scripts/check-interop-isolation.sh`
- Rust verification interop (hax / aeneas): `Interop/README.md`, `Interop/Aeneas/README.md`, `Interop/Aeneas/lakefile.toml`, `Interop/Aeneas/Lift/RustM.lean`, `scripts/check-interop-isolation.sh`

## Program Logic Tactics

Expand Down Expand Up @@ -310,7 +316,7 @@ the build just produced; `--test` runs it a second time over `VCVioTest` and

CI runs the timed build on the non-test Lean libraries:
`ToMathlib`, `VCVio`, `LatticeCrypto`, `Extern`, `HashSig`, and `Examples`.
The `Interop/` package builds separately.
Each `Interop/` sub-project builds separately, in its own CI job.
Test libraries and test executables are not part of the timed build; CI only
times the smoke module separately with `lake env lean VCVioTest/Smoke.lean`.

Expand All @@ -336,8 +342,8 @@ declaration in the non-test libraries, held at zero debt. Any declaration depend
(`native_decide`, which mints per-declaration `._native.` axioms). The committed baseline
`scripts/axiom_baseline.json` must stay `{"sorry": [], "nonstandard": []}`: a nonempty one
is a policy error rather than an allowlist, and `lake exe axiomsweep --update-baseline`
refuses to write one. `Interop/` (the declared TCB) is excluded — its boundary is enforced by
the import-isolation gate instead. The `VCVioAxiomSweepTestFixtures` library carries
refuses to write one. `Interop/` is excluded here: each sub-project's CI job sweeps the roots of
its default libraries against the same baseline. The `VCVioAxiomSweepTestFixtures` library carries
synthetic taint for the tool's own tests and is deliberately excluded from every
aggregate.

Expand All @@ -358,7 +364,8 @@ is the only thing that sees the doc-comment form anywhere; over the six proof an
libraries it deliberately repeats for the other forms what the whitespace linter already says;
and in three further places it is the only check that can *fail* on any form of the shape, for
three different reasons. `lakefile.lean` is elaborated by Lake from `import Lake`, with no
Mathlib linter registered. `Interop/` is not a default target and no job builds it. `scripts/`
Mathlib linter registered. `Interop/` is not a default target, and its sub-project jobs do not
gate on warnings. `scripts/`
is built on every pull request, but nothing there imports Mathlib, so the `weak.` option is
silently dropped and the linter is never registered — one Mathlib import in one axiom-sweep
fixture would flip that. A block comment that
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
module
public import Aeneas
public import CoreModels
public import Interop.Hax.Adc.Extraction.Types
public import Interop.Hax.Adc.Extraction.FunsExternal
public import Interop.Aeneas.Hax.Adc.Extraction.Types
public import Interop.Aeneas.Hax.Adc.Extraction.FunsExternal
@[expose] public section
open CoreModels Aeneas
open Aeneas.Std hiding namespace core alloc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
module
public import Aeneas
public import CoreModels
public import Interop.Hax.Adc.Extraction.Types
public import Interop.Aeneas.Hax.Adc.Extraction.Types
@[expose] public section
open CoreModels Aeneas
open Aeneas.Std hiding namespace core alloc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module
public import Aeneas
public import CoreModels
public import Hax
public import Interop.Hax.Adc.Extraction.Types
public import Interop.Hax.Adc.Extraction.Funs
public import Interop.Aeneas.Hax.Adc.Extraction.Types
public import Interop.Aeneas.Hax.Adc.Extraction.Funs
@[expose] public section
open CoreModels Aeneas
open Aeneas.Std hiding namespace core alloc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module
public import Aeneas
public import CoreModels
public import Interop.Hax.Adc.Extraction.TypesExternal
public import Interop.Aeneas.Hax.Adc.Extraction.TypesExternal
@[expose] public section
open CoreModels Aeneas
open Aeneas.Std hiding namespace core alloc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ Authors: Quang Dao, Devon Tuma
module

public import Hax
public import Interop.Hax.Adc.Extraction.Specs
public import Interop.Hax.Holds
public import Interop.Rust.RustM
public import Interop.Rust.Triple
public import Interop.Aeneas.Hax.Adc.Extraction.Specs
public import Interop.Aeneas.Hax.Holds
public import Interop.Aeneas.Lift.RustM
public import Interop.Aeneas.Lift.Triple
public import VCVio.ProgramLogic.Unary.WP.Necessary

/-!
# A Rust add-with-carry, extracted by hax, in VCVio

hax's `adc` example, the building block of multi-precision addition, vendored in the crate next to
this file (`Interop/Hax/Adc/src/lib.rs`):
this file (`Interop/Aeneas/Hax/Adc/src/lib.rs`):

```rust
#[hax_lib::requires(carry_in <= 1)]
Expand All @@ -35,12 +35,12 @@ pub fn adc_u32(a: u32, b: u32, carry_in: u32) -> (u32, u32) {
}
```

`scripts/regenerate-hax.sh` extracts it with the hax CLI into `Interop.Hax.Adc.Extraction`: the
function `hax_adc.adc_u32`, its `requires` and `ensures` clauses as `adc_u32.pre` and
`adc_u32.post`, and its contract `adc_u32.spec`. The contract is proved by hax's own proof of it,
with `hax_mvcgen` and `scalar_tac`. Its clauses read as plain arithmetic (`adcPost`), and it reaches
VCVio's program logic, under any `Prop`-valued interpretation of oracle computations, through
`Interop.Rust.triple_liftRustM_of_imp`.
`scripts/regenerate-hax.sh` extracts it with the hax CLI into
`Interop.Aeneas.Hax.Adc.Extraction`: the function `hax_adc.adc_u32`, its `requires` and `ensures`
clauses as `adc_u32.pre` and `adc_u32.post`, and its contract `adc_u32.spec`. The contract is
proved by hax's own proof of it, with `hax_mvcgen` and `scalar_tac`. Its clauses read as plain
arithmetic (`adcPost`), and it reaches VCVio's program logic, under any `Prop`-valued
interpretation of oracle computations, through `Interop.Rust.triple_liftRustM_of_imp`.

## Main results

Expand Down
5 changes: 5 additions & 0 deletions Interop/Aeneas/Hax/Adc/hax.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Extract into the Lean modules `Interop.Aeneas.Hax.Adc.Extraction.*` next to this crate.
[scenario.adc]
backend = "lean"
project-files = false
aeneas-args = ["-dest", "../../../..", "-subdir", "Interop/Aeneas/Hax/Adc/Extraction"]
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
//! `#[hax_lib::requires(..)]` and `#[hax_lib::ensures(..)]`. The Lean
//! backend turns them into a specification `adc_u32.spec`
//! in the generated `Extraction/Specs.lean`, proved correct in
//! `Interop/Hax/Adc/Verification.lean` with hax's own proof script.
//! `Interop/Aeneas/Hax/Adc/Verification.lean` with hax's own proof script.
//!
//! The proof uses `hax_mvcgen` to generate the verification conditions, which in turn are
//! discharged using `simp`, `grind`, and `scalar_tac`.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
module
public import Aeneas
public import CoreModels
public import Interop.Hax.Barrett.Extraction.Types
public import Interop.Hax.Barrett.Extraction.FunsExternal
public import Interop.Aeneas.Hax.Barrett.Extraction.Types
public import Interop.Aeneas.Hax.Barrett.Extraction.FunsExternal
@[expose] public section
open CoreModels Aeneas
open Aeneas.Std hiding namespace core alloc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
module
public import Aeneas
public import CoreModels
public import Interop.Hax.Barrett.Extraction.Types
public import Interop.Aeneas.Hax.Barrett.Extraction.Types
@[expose] public section
open CoreModels Aeneas
open Aeneas.Std hiding namespace core alloc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module
public import Aeneas
public import CoreModels
public import Hax
public import Interop.Hax.Barrett.Extraction.Types
public import Interop.Hax.Barrett.Extraction.Funs
public import Interop.Aeneas.Hax.Barrett.Extraction.Types
public import Interop.Aeneas.Hax.Barrett.Extraction.Funs
@[expose] public section
open CoreModels Aeneas
open Aeneas.Std hiding namespace core alloc
Expand Down
Loading
Loading