betrusted-ed25519-verified/verification/gen/CurveScalar/FunsExternal.lean
mrwulf 6120f9bb17 Add scalar-layer foundation (Scalar52 arithmetic mod ℓ)
Transpile the Scalar52 limb backend (backend::serial::u64::scalar
add/sub/mul/square/montgomery_*) from Rust to Lean via Charon/Aeneas,
scoped at the function level to the iterator-free arithmetic core.

  - verification/extract-scalar.sh: function-level Charon/Aeneas extraction
  - verification/gen/CurveScalar/{Types,Funs}.lean: transpiled model (27 defs).
    This fork (v4.1.2) implements Scalar52::sub's constant-time conditional add
    with a pure arithmetic mask (constants::L[i] & underflow_mask), so the
    extraction pulls in NO external functions or types (unlike v5 dalek, which
    routes sub through subtle, and v4.1.3, which uses a local black_box).
  - verification/gen/CurveScalar/{TypesExternal,FunsExternal}.lean: decl-free
    stub modules kept so the check manifest is uniform across forks.
  - verification/Proofs/ScalarDenote.lean: semantic foundation — Scalar52
    denotation into ℤ/ℓℤ, limb-bound invariant, and L_val (the transpiled
    constants::L denotes exactly the group order ℓ, kernel-checked).
  - verification/check-scalar.sh: guarded compile of the gen modules plus the
    denotation foundation.

check-scalar.sh passes: gen compiles; denotation + L = ℓ proven.
add/sub/mul remain in progress.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 21:27:33 +02:00

16 lines
788 B
Text

-- Hand-written external function models for the Scalar52 arithmetic extraction.
-- This fork (curve25519-dalek v4.1.2) implements Scalar52::sub's constant-time
-- conditional add with a pure arithmetic mask (`constants::L[i] & underflow_mask`),
-- so the function-level scalar extraction pulls in NO external functions
-- (unlike the v5 dalek, which routes sub through subtle, and v4.1.3, which uses
-- a local `black_box`). Kept as a (decl-free) module so the check manifest is
-- uniform across forks.
import Aeneas
import CurveScalar.Types
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option maxHeartbeats 1000000
set_option maxRecDepth 2048
open curve25519_dalek