dalek-ed25519-verified/README.md

82 lines
3.9 KiB
Markdown
Raw Normal View History

# dalek-ed25519-verified
Formal verification of the ed25519 implementation in **dalek-cryptography/curve25519-dalek (upstream, v5.0.0-rc.1)**, built as a
coherent proof pyramid in Lean 4 via the Charon/Aeneas transpilation pipeline:
```
┌──────────────────────────────┐
│ Signature (EdDSA verify) │ accepted ⇒ [8][S]B = [8]R + [8][k]A
├──────────────────────────────┤
│ Scalar arithmetic mod │ Scalar52 ops correct mod
├──────────────────────────────┤
│ Group law (twisted Edwards) │ point ops = complete addition law
├──────────────────────────────┤
│ Field 𝔽_p, p = 2²⁵⁵ 19 │ FieldElement51 ops correct mod p
└──────────────────────────────┘
```
Every layer states its theorems about the **actual Aeneas-transpiled Rust
code** (never about a hand-written re-model), and every claim in the status
table below is backed by a compiled proof plus an axiom audit of the named
certificate. Files that do not compile under `verification/check.sh` are not
in this repository.
## Layer status
| Layer | Certificate | Status | Axioms of certificate |
|-------|-------------|--------|-----------------------|
| Field 𝔽_p | `fieldImplementation` | ✅ proven | `[propext, Classical.choice, Quot.sound]` |
| Group law (Edwards) | `edwardsImplementation` | ✅ proven | `[propext, Classical.choice, Quot.sound]` |
scalar layer: prove Scalar52::sub borrow + conditional-add-L carry chains New in Proofs/ScalarSubSpec.lean (all axiom-clean [propext, Classical.choice, Quot.sound], no sorry, no native_decide): - nat_and_mask52 / nat_shift52 / nat_shift63 : 52/63-bit ops -> %,/ - sub_step_arith : isolated per-limb borrow accounting (tiny ℕ context, correction-on-the-left so no truncated subtraction) — the METHOD-4 discipline that keeps 2^260-scale coefficients out of any one certificate - sub_loop_spec : the FULL 5-limb borrow chain of Scalar52::sub, unrolled via loop_step/range_next_*; wrapping_sub, 52-bit mask store, borrow-out bit. This is the loop unroll that blocked the earlier attempt. - csel_step : step-spec for the subtle conditional_select (faithful model) - cond_add_l_zero_spec / cond_add_l_one_spec : BOTH cases of conditional add-of-L, full carry chains; the condition-1 case steps the addend as a clean value so the index_mut write-back matches sub_loop's pattern - sub_telescope / add_telescope : the 2^52i-weighted value telescopes to 2^260, discharged by omega (no kernel-capacity blowup) check-scalar.sh: ScalarSubSpec added to the compile manifest; Phase-3 axiom audit extended to sub_loop_spec + cond_add_l_one_spec (3/3 clean). Full button green. Honest boundary: top-level sub_val_spec (⟦sub a b⟧ = ⟦a⟧-⟦b⟧ in ZMod ℓ) is documented as remaining — every lemma it needs is proven; what's left is the Aeneas binding-arity for destructuring sub_loop_spec's pair-valued multi-existential postcondition inside the do-block, a mechanical not a mathematical gap. No sorry shipped (Invariants H1/H4). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 14:26:24 +00:00
| Scalar mod | `scalarImplementation` (planned; `L_val`, `sub_loop_spec`, `cond_add_l_*_spec` proven) | 🔨 foundation+sub | denotation + L= + sub borrow/carry chains proven; sub value-assembly & mul in progress |
| Signature (EdDSA) | `verifyEquation` (planned) | ⏳ planned | — |
Status legend: ✅ proven & axiom-audited · ⏳ in progress · ❌ not started.
This table is updated only when `verification/check.sh` passes for the layer.
## Source
- **Upstream**: [dalek-cryptography/curve25519-dalek](https://github.com/dalek-cryptography/curve25519-dalek), commit `4cf8db2`
- **Pinned/patched source**: [saymrwulf/curve25519-dalek-source](https://github.com/saymrwulf/curve25519-dalek-source), commit `135ed70`
- **Patches**: minimal Aeneas-compatibility only (documented in the source repo)
- Verified backend: `backend/serial/u64` (`FieldElement51`, `Scalar52`). SIMD/AVX backends are out of scope (marked opaque).
## Toolchain (pinned)
| Component | Version |
|-----------|---------|
| Aeneas | `bf13c42e` |
| Charon | `9dd7f23c` |
| Lean | `v4.30.0-rc2` |
| OCaml | `5.3.0` |
## Reproducing
```bash
source ~/aeneas-toolchain/env.sh
cd verification
./extract.sh # Rust → LLBC → Lean (regenerates gen/)
./check.sh # compiles EVERY shipped file + axiom-audits EVERY certificate
```
The scalar layer has its own pair of buttons:
```bash
./extract-scalar.sh # regenerates gen/CurveScalar (Scalar52 limb arithmetic)
./check-scalar.sh # compiles the scalar gen + the proven scalar foundation
```
## Trusted base
See [TRUSTED-BASE.md](TRUSTED-BASE.md) for the complete list of assumptions
(Lean kernel, mathlib, Charon/Aeneas semantics, external-function models,
and — in the signature layer only — an opaque SHA-512 model).
## Provenance
Proof engineering in this repository builds on the verification methodology
and proof architecture of
[PlanetMacro/ed25519-verificationtest](https://github.com/PlanetMacro/ed25519-verificationtest)
(the reference solution). All proofs here are checked against **this fork's
own extracted code**; nothing is claimed that the check script does not compile.