Documentation

CslibFrontier.Crypto.Computational.MerkleTree.Extract

Multi-opening Merkle-tree commitment extraction #

Given any list of claimed openings against a Merkle root rt at depth d, merkleExtractVector reconstructs a committed vector of length len by reading the first accepted opening of each index (and filling unqueried slots with a default word), while merkleVectorBindingOutput searches for two accepted openings of the same index to different leaves:

All extraction and conflict-search functions carry ComputableInPolyTime certificates, and merkleVectorBindingOutput produces a MerkleBindingOutput satisfying merkleBreaksBinding for downstream standard-model binding reductions via CollisionResistantOn.merklePositionBinding or merklePositionBinding_of_hashFamily.

Main definitions #

Main results #

References #

An indexed Merkle opening pairs a leaf position with a bit-string leaf opening.

  • position : ℕ

    The leaf index opened.

  • opening : MerkleOpening (List Bool)

    The claimed bit-string leaf and authentication path.

Instances For
    theorem Cslib.Crypto.encMerkleIndexedOpening_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 T0 S0 : γ → ℕ} {x1 : γ → MerkleOpening (List Bool)} {T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encUnary T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn encMerkleOpening T1 S1) :
    Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { position := x0 x, opening := x1 x }) encIn encMerkleIndexedOpening (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x
    theorem Cslib.Crypto.encMerkleIndexedOpening_position_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → MerkleIndexedOpening} :

    The encoding of an indexed Merkle opening: the unary index, then the bit-string opening.

    theorem Cslib.Crypto.encMerkleIndexedOpening_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget x0 : γ → ℕ} {x1 : γ → MerkleOpening (List Bool)} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn Turing.MultiTapeTM.encUnary budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn encMerkleOpening budget) :
    Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { position := x0 x, opening := x1 x }) encIn encMerkleIndexedOpening budget
    theorem Cslib.Crypto.encMerkleIndexedOpening_opening_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → MerkleIndexedOpening} :

    Keep only openings whose index is below len and whose opening passes merkleVerify.

    Reconstruct a len-entry leaf vector from openings by taking the first opening matching each index below len, falling back to defaultLeaf at unopened positions.

    Find the first pair of entries in openings that open the same index to different leaves.

    Convert the first conflict in openings against root into a MerkleBindingOutput.

    @[simp]
    theorem Cslib.Crypto.length_merkleExtractVector (len : ℕ) (defaultLeaf : List Bool) (openings : List MerkleIndexedOpening) :
    (merkleExtractVector len defaultLeaf openings).length = len
    @[simp]
    theorem Cslib.Crypto.mem_merkleVerifiedOpenings {H : List Bool → List Bool → List Bool} {k : List Bool} {d len : ℕ} {root : List Bool} {openings : List MerkleIndexedOpening} {entry : MerkleIndexedOpening} :
    entry ∈ merkleVerifiedOpenings H k d len root openings ↔ entry ∈ openings ∧ entry.position < len ∧ MerkleOpening.verify H k id d root entry.position entry.opening = true
    theorem Cslib.Crypto.merkleBreaksBinding_merkleVectorBindingOutput {H : List Bool → List Bool → List Bool} {leafSpace : ℕ → List Bool → Bool} {n : ℕ} {k : List Bool} {d : ℕ} {root : List Bool} {openings : List MerkleIndexedOpening} (hvalid : ∀ entry ∈ openings, leafSpace n entry.opening.leaf = true ∧ MerkleOpening.verify H k id d root entry.position entry.opening = true) {o₁ o₂ : MerkleIndexedOpening} (ho₁ : o₁ ∈ openings) (ho₂ : o₂ ∈ openings) (hpos : o₁.position = o₂.position) (hle : o₁.opening.leaf ≠ o₂.opening.leaf) :
    merkleBreaksBinding H leafSpace n k (merkleVectorBindingOutput root openings) = true

    If every entry in openings is verified at depth d against root and lies in leafSpace n, then any conflicting pair at the same index makes merkleVectorBindingOutput break position binding.

    theorem Cslib.Crypto.getD_merkleExtractVector_eq_of_conflict_eq_none (len : ℕ) (defaultLeaf : List Bool) {openings : List MerkleIndexedOpening} (hnone : merkleOpeningConflict openings = none) {entry : MerkleIndexedOpening} (hent : entry ∈ openings) (hlt : entry.position < len) :
    (merkleExtractVector len defaultLeaf openings).getD entry.position defaultLeaf = entry.opening.leaf

    When merkleOpeningConflict openings = none, every entry below len agrees with merkleExtractVector.

    theorem Cslib.Crypto.getD_merkleExtractVector_or_merkleBreaksBinding {H : List Bool → List Bool → List Bool} {leafSpace : ℕ → List Bool → Bool} {n : ℕ} {k : List Bool} {d len : ℕ} {root : List Bool} (defaultLeaf : List Bool) {openings : List MerkleIndexedOpening} (hleaf : ∀ entry ∈ merkleVerifiedOpenings H k d len root openings, leafSpace n entry.opening.leaf = true) :
    have verified := merkleVerifiedOpenings H k d len root openings; merkleBreaksBinding H leafSpace n k (merkleVectorBindingOutput root verified) = true ∨ ∀ entry ∈ verified, (merkleExtractVector len defaultLeaf verified).getD entry.position defaultLeaf = entry.opening.leaf

    Commitment-vector consistency or position-binding break: filtering openings to verified openings below len, either every verified opening in openings below len agrees with the reconstructed vector merkleExtractVector, or merkleVectorBindingOutput breaks merkleBreaksBinding (assuming verified openings have leaves in leafSpace n).

    Reconstructing merkleExtractVector from indexed openings takes polynomial time.