Files
magnetar/proofs/easycrypt/lemmas/SLHDSA_Functional.ec
T
Hanzo AI 3c832acef6 magnetar v1.1: restore EasyCrypt + Lean proof track for strict-atom path
Closes MAGNETAR-PROOF-TRACK-V11.

Theory files (proofs/easycrypt/):
  - Magnetar_N1_StrictAtom.ec --- Class N1-analog strict-atom byte-
    equality theorem. Headline statement:

      forall m pkSeed pkRoot msg ctx picks lambdas,
        valid_quorum picks =>
        lagrange_basis_at_zero picks = lambdas =>
        assemble_signature_bytes m pkSeed pkRoot msg ctx picks lambdas
          = slh_sign_deterministic m
              (sk_from_seed m (lagrange_sum lambdas picks)) msg ctx.

    Discharged via combine_assemble_axiom (Go extraction trust
    boundary).

  - Magnetar_N1_SHAKE_Expand.ec --- FIPS 205 sec 10.1 SHAKE expansion
    lemmas. Cross-cites shake256_functional (Lean Crypto.Lux.SHA3).

  - Magnetar_N1_Atom_Refinement.ec --- Magnetar-internal sec 5-8 walk
    refines circl FIPS 205 dispatch. Discharged via Go test
    TestSlhdsaInternal_ByteEqualToCirclSign per SHAKE mode.

  - Magnetar_N4_KeyDeriveStable.ec --- same-master-yields-same-pk
    lemma for reshare/rotation analysis. 0 admits.

  - lemmas/SLHDSA_Functional.ec --- FIPS 205 sec 11.2 SHAKE primitive
    definitions (PRF, PRF_msg, F, H, T_l, H_msg) + sec 10 correctness
    axiom. 4 admits (black-box specs).

  - lemmas/Magnetar_CT.ec --- Bernstein-Garcia-Levy leakage-model CT
    lemma. 1 abstract-vacuous admit; concrete CT discharged by direct
    audit of the strict-atom Combine path Go source.

Lean bridge (proofs/lean/Crypto/Magnetar/StrictAtom.lean):
  - byte_wise_shamir_lagrange_at_zero_identity (shared with
    Crypto.Pulsar.Shamir).
  - shake256_functional (shared with Crypto.Lux.SHA3).
  - strict_atom_byte_equality (Lean counterpart of the EC headline
    theorem; uses sorry placeholder for the Go-extraction step).
  - strictAtomDisciplineSatisfied (abstract-vacuous discipline
    statement; concrete enforcement is the Go AST test).

Axiom budget: 5 substantive + 1 abstract-vacuous CT admit (down from
the v0.4 cascade's 14-axiom cone). Per proofs/README.md.

Bridge doc (proofs/lean-easycrypt-bridge.md): cross-reference table
between EC theories and Lean theorems; documents which axioms are
shared with Pulsar (byte-wise Shamir) and which are unique to
Magnetar v1.1 (the strict-atom discipline statement).
2026-06-01 17:13:24 -07:00

75 lines
3.6 KiB
Plaintext

(* -------------------------------------------------------------------- *)
(* SLHDSA_Functional --- FIPS 205 SHAKE functional spec *)
(* -------------------------------------------------------------------- *)
(* *)
(* STATUS: 4 admits (FIPS 205 sec 11.2 SHAKE primitive definitions *)
(* lifted as black-box ops; the FIPS 205 sec 10 correctness axiom is *)
(* a black-box claim from NIST verification). *)
(* *)
(* The FIPS 205 sec 11.2 SHAKE primitives: *)
(* *)
(* PRF(PK.seed, ADRS, SK.seed) = SHAKE256(PK.seed || ADRS || SK.seed)[:n] *)
(* PRF_msg(SK.prf, optRand, M) = SHAKE256(SK.prf || optRand || M)[:n] *)
(* F(PK.seed, ADRS, M_1) = SHAKE256(PK.seed || ADRS || M_1)[:n] *)
(* H(PK.seed, ADRS, M_1||M_2) = SHAKE256(PK.seed || ADRS || M_1 || M_2)[:n] *)
(* T_l(PK.seed, ADRS, M) = SHAKE256(PK.seed || ADRS || M)[:n] *)
(* H_msg(R, PK.seed, PK.root, M) = SHAKE256(R || PK.seed || PK.root || M)[:m] *)
(* *)
(* The single-party correctness of FIPS 205 SLH-DSA SignDeterministic *)
(* is the standard "if SignDeterministic returns sig, then Verify(pk, *)
(* msg, sig) accepts" claim, modulo the FIPS 205 sec 10 well-formedness *)
(* conditions on inputs. *)
(* *)
(* -------------------------------------------------------------------- *)
require import AllCore List Int IntDiv.
type byte = int.
type bytes = byte list.
type mode = [ M192s | M192f | M256s ].
op n_of_mode : mode -> int.
(* FIPS 205 sec 11.2 SHAKE family --- PRF (FORS leaf / WOTS+ chain
base derivation). *)
op slhdsa_prf :
mode -> bytes (* pk_seed *) -> bytes (* addr *) -> bytes (* sk_seed *) -> bytes.
axiom slhdsa_prf_size : forall m pkSeed addr skSeed,
size (slhdsa_prf m pkSeed addr skSeed) = n_of_mode m.
(* FIPS 205 sec 11.2 SHAKE family --- PRF_msg (signature randomizer). *)
op slhdsa_prf_msg :
mode -> bytes (* sk_prf *) -> bytes (* opt_rand *) -> bytes (* msg' *) -> bytes.
axiom slhdsa_prf_msg_size : forall m skPrf optRand msg,
size (slhdsa_prf_msg m skPrf optRand msg) = n_of_mode m.
(* The packed sk byte layout: 4n bytes.
sk = skSeed || skPrf || pkSeed || pkRoot. *)
op pack_sk : mode -> bytes -> bytes -> bytes -> bytes -> bytes.
(* The FIPS 205 sk_from_seed driver: derive (skSeed, skPrf, pkSeed) via
SHAKE256 expansion, compute pkRoot via the inner setup primitive,
pack the result. *)
op sk_from_seed : mode -> bytes -> bytes.
(* The two "secret-segment extractors" used in
Magnetar_N1_Atom_Refinement to discharge the closure-equivalence.
These are abstract values that capture "the n-byte secret material
the closure feeds at every PRF / PRF_msg call". *)
op slhdsa_prf_secret_for_atom : mode -> (bytes -> bytes -> bytes) -> bytes.
op slhdsa_prf_msg_secret_for_atom : mode -> (bytes -> bytes -> bytes) -> bytes.
(* FIPS 205 sec 10 correctness: SignDeterministic produces a verifiable
signature for any well-formed sk. Black-box from NIST. *)
op slh_sign_deterministic : mode -> bytes -> bytes -> bytes -> bytes.
op slh_verify : mode -> bytes (* pk *) -> bytes -> bytes -> bytes -> bool.
op pk_from_sk : mode -> bytes -> bytes.
axiom slhdsa_correctness :
forall m sk msg ctx,
slh_verify m (pk_from_sk m sk) msg
(slh_sign_deterministic m sk msg ctx) ctx
= true.