{
  "schema": "blueprint-dag.v1",
  "id": "leansphincs-mainnet-wallet",
  "problem": "verified-ethereum",
  "workstream": "W3-A",
  "title": "leanSPHINCS Mainnet AA / Multisig Wallet (3-Mode EIP-8141 + FOCIL)",
  "description": "Multi-layer formalization and Glamsterdam EVM bytecode refinement DAG for a FOCIL-safe k-of-n leanSPHINCS smart account supporting Mode 1 (in-EVM SPHINCS- C13), Mode 2 (EIP-8504 native leanSPHINCS), and Mode 3 (EIP-8288 off-chain WHIR batch claim) with irreversible SETCODEFROM EOA migration.",
  "policyVersion": 8,
  "trunkEpoch": 0,
  "trunkCheckpointRef": null,
  "upstreamPins": {
    "toolchain": "leanprover/lean4:v4.36.0",
    "ethlibCommit": "212d502f4cdecf59985e427a7c31e5a623be5416",
    "evmSemantics": "EthLib.Execution.Evm.runFrame (Fork.glamsterdam)",
    "sphincsSpec": "EthLib.Cryptography.Sphincs.verify"
  },
  "nodes": [
    {
      "id": "W3A.Spec",
      "kind": "spec",
      "title": "3-Mode EIP-8141 Wallet State Machine & Signing Spec",
      "statementSummary": "Formalizes canonical 83-byte txSignPreimage, 96-byte DepClaim96 (EIP-8288), FOCIL isolated storage layout (slots 0x00, 0x01, 2D nonce lane map), and 3-mode validation semantics over EthLib.Cryptography.Sphincs.verify.",
      "leanTarget": {
        "modulePath": "lean/WalletSpec.lean",
        "topTheorem": "Wave3.Wallet.spec_well_formed"
      },
      "dependsOn": [],
      "status": "ready",
      "claim": null,
      "settlement": null,
      "decomposition": null,
      "ratchet": null
    },
    {
      "id": "W3A.PreimageInjectivity",
      "kind": "lemma",
      "title": "83-Byte EIP-8141 Preimage & DepClaim96 Domain Injectivity",
      "statementSummary": "Proves collision-free domain separation across authMode in {0x01, 0x02, 0x03}, chainId, account address, signer-rotation epoch, and 2D nonce coordinates, ruling out cross-mode signature downgrade or replay.",
      "leanTarget": {
        "modulePath": "lean/PreimageInjectivity.lean",
        "topTheorem": "Wave3.Wallet.txSignPreimage_injective"
      },
      "dependsOn": [
        "W3A.Spec"
      ],
      "status": "pending",
      "claim": null,
      "settlement": null,
      "decomposition": null,
      "ratchet": null
    },
    {
      "id": "W3A.KeccakScratchpad",
      "kind": "lemma",
      "title": "In-Place EVM Keccak-256 Scratchpad & Memory Aliasing Lemma",
      "statementSummary": "Proves exact equivalence between the EVM runtime memory scratchpad Keccak-f[1600] / KECCAK256 opcode helper and EthLib's pure byte-slice Keccak specification with bounded Glamsterdam memory expansion gas.",
      "leanTarget": {
        "modulePath": "lean/KeccakScratchpad.lean",
        "topTheorem": "Wave3.Wallet.keccakScratchpad_refines"
      },
      "dependsOn": [
        "W3A.Spec"
      ],
      "status": "pending",
      "claim": null,
      "settlement": null,
      "decomposition": null,
      "ratchet": null
    },
    {
      "id": "W3A.WotsPlusCLoop",
      "kind": "lemma",
      "title": "WOTS+C Checksum-Free Hash Chain Loop Refinement",
      "statementSummary": "Proves loop invariant and termination for EVM bytecode evaluating C13/leanSPHINCS WOTS+C chains (w=8, v=43, T=151 / w=4, 64 chains, T=128) against EthLib.Cryptography.Sphincs.wotsVerify.",
      "leanTarget": {
        "modulePath": "lean/WotsPlusCLoop.lean",
        "topTheorem": "Wave3.Wallet.wotsLoop_refines"
      },
      "dependsOn": [
        "W3A.Spec",
        "W3A.KeccakScratchpad"
      ],
      "status": "pending",
      "claim": null,
      "settlement": null,
      "decomposition": null,
      "ratchet": null
    },
    {
      "id": "W3A.ForsPlusCLoop",
      "kind": "lemma",
      "title": "FORS+C Merkle Leaf & Authentication Path Loop Refinement",
      "statementSummary": "Proves that EVM FORS+C tree-root reconstruction over k=8, a=16, z=16 (or native 24x10) matches EthLib's FORS+C public-key recovery without bit-truncation or index-shift errors.",
      "leanTarget": {
        "modulePath": "lean/ForsPlusCLoop.lean",
        "topTheorem": "Wave3.Wallet.forsLoop_refines"
      },
      "dependsOn": [
        "W3A.Spec",
        "W3A.KeccakScratchpad"
      ],
      "status": "pending",
      "claim": null,
      "settlement": null,
      "decomposition": null,
      "ratchet": null
    },
    {
      "id": "W3A.MultisigAndRotation",
      "kind": "lemma",
      "title": "k-of-n Signer Merkle Threshold & Epoch-Monotone Rotation",
      "statementSummary": "Proves sorted unique signer index enforcement, threshold k-of-n Merkle membership, permanent SETCODEFROM EOA key retirement, and strictly monotone signer-rotation epoch counter.",
      "leanTarget": {
        "modulePath": "lean/MultisigRotation.lean",
        "topTheorem": "Wave3.Wallet.multisig_epoch_monotone"
      },
      "dependsOn": [
        "W3A.Spec",
        "W3A.PreimageInjectivity"
      ],
      "status": "pending",
      "claim": null,
      "settlement": null,
      "decomposition": null,
      "ratchet": null
    },
    {
      "id": "W3A.FocilStorageIsolation",
      "kind": "lemma",
      "title": "EIP-8141 VERIFY Frame & FOCIL Mempool Non-Interference",
      "statementSummary": "Proves via EthLib.Execution.Evm.runFrame state footprint analysis that Mode 1/2/3 VERIFY frames touch only the account's isolated slots (0x00, 0x01, lane nonce) and transient 0x8288 depsHash, guaranteeing prefix-tx non-interference.",
      "leanTarget": {
        "modulePath": "lean/FocilIsolation.lean",
        "topTheorem": "Wave3.Wallet.focil_verify_isolated"
      },
      "dependsOn": [
        "W3A.Spec"
      ],
      "status": "pending",
      "claim": null,
      "settlement": null,
      "decomposition": null,
      "ratchet": null
    },
    {
      "id": "W3A.MainRefinement",
      "kind": "evm-refinement",
      "title": "End-to-End validateFrame Bytecode-to-EthLib Refinement",
      "statementSummary": "Composes preimage injectivity, Keccak scratchpad, WOTS+C/FORS+C loops, multisig rotation, and FOCIL isolation into Wave3.Wallet.validateFrame_refines_spec over the deployed Glamsterdam runtimeHex.",
      "leanTarget": {
        "modulePath": "lean/WalletMainRefinement.lean",
        "topTheorem": "Wave3.Wallet.validateFrame_refines_spec"
      },
      "dependsOn": [
        "W3A.PreimageInjectivity",
        "W3A.KeccakScratchpad",
        "W3A.WotsPlusCLoop",
        "W3A.ForsPlusCLoop",
        "W3A.MultisigAndRotation",
        "W3A.FocilStorageIsolation"
      ],
      "status": "pending",
      "claim": null,
      "settlement": null,
      "decomposition": null,
      "ratchet": null
    },
    {
      "id": "W3A.GasRecord_Sub100k",
      "kind": "synthesis-record",
      "title": "Quantitative Gas Frontier: In-EVM leanSPHINCS < 100k Glamsterdam Gas",
      "statementSummary": "Quantitative synthesis ratchet tracking worst-case Glamsterdam execution + calldata gas for validateFrame against the 127,000 gas SPHINCS- C13 baseline, targeting < 100,000 gas with checked EthLib refinement.",
      "leanTarget": {
        "modulePath": "lean/WalletGasRecord.lean",
        "topTheorem": "Wave3.Wallet.validateFrame_gas_bound"
      },
      "dependsOn": [
        "W3A.MainRefinement"
      ],
      "status": "pending",
      "claim": null,
      "settlement": null,
      "decomposition": null,
      "ratchet": {
        "metric": "evm_gas",
        "direction": "minimize",
        "baselineValue": 127000,
        "targetThreshold": 100000,
        "currentBest": null,
        "history": [],
        "open": true
      }
    }
  ]
}
