Straight-line Merkle trace extraction in the random-oracle model #
In the standard model, extracting the committed table of a Merkle tree from a cheating prover
requires rewinding two accepting executions on the same commitment and finding a conflicting pair
of openings (CslibFrontier.Crypto.Computational.MerkleTree.Binding,
CslibFrontier.Crypto.Computational.Kilian.Soundness). In the random-oracle model, as in Micali's
computationally sound proofs and the BCS transformation ([BSCS16]; see also
Chiesa and Yogev, Building Cryptographic Proofs from Hash Functions, Construction 18.5.3 and
Lemma 18.5.7), extraction is straight-line: given the query-answer trace
tr : List (List Bool × List Bool) of hash queries (q, ans) made so far, one can
deterministically reconstruct the unique table committed under a Merkle root rt at depth d
without rewinding.
Extraction from a query trace #
The tree of CslibFrontier.Crypto.Computational.MerkleTree hashes a leaf x to H k x and pairs
two
child nodes (l, r) into encPair encBits encBits (l, r) = frame l ++ r, which unframe and
dropFrame invert on every encoded pair:
findQueryInTrace tr digestreturns the first queryqrecorded intrwith answerdigest.findPreimageInTrace tr digestdecodes that query into(unframe q, dropFrame q), the candidate left and right child digests of an internal node.extractNodeFromTrace tr d rt iwalksdlevels down fromrtalong the binary digits(i / 2 ^ level) % 2of positioni, returning the level-0leaf digest.extractLeafFromTrace tr d rt iinverts that level-0digest intrto recover the leaf at positioni, andextractTableFromTrace tr d rt defaultLeaftabulates all2 ^ dpositions.
Consistency and collision extraction #
- Consistency (
extractLeafFromTrace_eq_some_of_merkleVerify): iftrhas no output collisions (TraceCollisionFree tr) and records every hash evaluation along a valid depth-dopening (PathQueriedInTrace H k tr i leaf pathandmerkleVerify H k d rt i leaf path = true), thenextractLeafFromTrace tr d rt i = some leaf, and entryiofextractTableFromTrace tr d rt defaultLeafisleaf(getD_extractTableFromTrace_eq_of_merkleVerify). Any two openings of positioniaccepted againstrtwhose paths are recorded in a collision-free trace must therefore open to the same leaf (leaf_eq_of_merkleVerify_of_traceCollisionFree). - Dual collision extraction (
extractTraceCollision,isCollision_extractTraceCollision): conversely, iftris consistent withH k(TraceConsistentWith (H k) tr) and records all hash steps of an accepted opening(leaf, path)at positioni, yetextractLeafFromTrace tr d rt i ≠ some leaf, thenextractTraceCollision H k tr i leaf pathdeterministically extracts a collision(q₁, q₂)fromtrwithq₁ ≠ q₂andH k q₁ = H k q₂.
Random-oracle collision and preimage bounds #
For a lazy random oracle sampling uniform m-bit digests
(memoize (fun _ => BitString.uniformList m)):
toOuterMeasure_uniformList_mem_list_lebounds the probability that a freshm-bit digest hits a listtargetsof digests bytargets.length * (1 / 2 ^ m).toOuterMeasure_memoize_not_traceCollisionFree_stepbounds the probability that one memoized oracle call from a collision-free tracetrcreates a collision bytr.length * (1 / 2 ^ m).toOuterMeasure_run_memoize_not_traceCollisionFree_lecomposes this per-call bound viaOracleComp.toOuterMeasure_bad_le: any program making at mostQoracle queries produces a collision in its final trace with probability at mostQ * (Q * (1 / 2 ^ m)).
Main definitions #
Cslib.Crypto.TraceConsistentWith,Cslib.Crypto.TraceCollisionFree,Cslib.Crypto.PathQueriedInTrace: trace consistency, collision-freeness, and path coverage.Cslib.Crypto.findQueryInTrace,Cslib.Crypto.findPreimageInTrace: trace inversion primitives.Cslib.Crypto.extractNodeFromTrace,Cslib.Crypto.extractLeafFromTrace,Cslib.Crypto.extractTableFromTrace: straight-line Merkle node, leaf, and table extractors.Cslib.Crypto.extractTraceCollision: deterministic collision extractor when trace extraction disagrees with an accepted opening.Cslib.Crypto.encMerkleTrace: encoding of a Merkle hash query-answer trace.
Main results #
Cslib.Crypto.extractLeafFromTrace_eq_some_of_merkleVerify,Cslib.Crypto.getD_extractTableFromTrace_eq_of_merkleVerify: straight-line extraction agrees with every valid opening whose path is in a collision-free trace.Cslib.Crypto.extractLeafFromTrace_cons_of_ne,Cslib.Crypto.extractTableFromTrace_cons_of_ne: straight-line leaf and table extraction are invariant under prepending a Merkle query whose digest avoids the root and existing query children.Cslib.Crypto.isCollision_extractTraceCollision,Cslib.Crypto.exists_collision_of_extractLeafFromTrace_ne: disagreement between an accepted queried opening and the trace extractor yields an explicit hash collision in the trace.Cslib.Crypto.toOuterMeasure_uniformList_mem_list_le,Cslib.Crypto.toOuterMeasure_memoize_not_traceCollisionFree_step,Cslib.Crypto.toOuterMeasure_run_memoize_not_traceCollisionFree_le,Cslib.Crypto.mem_support_memoize_nodup: union bounds and trace-support invariants for lazy random oracles.Cslib.Crypto.computableInPolyTime_findQueryInTrace,Cslib.Crypto.computableInPolyTime_findPreimageInTrace,Cslib.Crypto.computableInPolyTime_extractNodeFromTrace,Cslib.Crypto.computableInPolyTime_extractLeafFromTrace,Cslib.Crypto.computableInPolyTime_extractTableFromTrace,Cslib.Crypto.computableInPolyTime_extractTraceCollision,Cslib.Crypto.computableInPolyTime_decide_traceConsistentWith,Cslib.Crypto.computableInPolyTime_decide_pathQueriedInTrace: plain polynomial-time certificates for straight-line trace extraction, collision extraction, and trace predicates.
References #
Trace consistency and collision predicates #
If findQueryInTrace tr digest = some q, then (q, digest) is a recorded entry of tr.
In a trace consistent with h, any query returned by findQueryInTrace tr digest hashes to
digest under h.
If (q, digest) ∈ tr, then findQueryInTrace tr digest succeeds and returns some query
recorded with digest in tr.
In a collision-free trace, findQueryInTrace tr digest recovers the unique query q recorded
with digest.
Prepending (q, ans) to tr leaves findQueryInTrace at digest unchanged whenever
ans ≠ digest.
Straight-line Merkle trace extraction #
Every hash evaluation along the recomputation of the root from leaf at position i along
path appears as a recorded (q, H k q) entry in tr.
Instances For
If tr is consistent with H k and every hash input along merkleInputs H k leaf i path
appears in tr.map Prod.fst, then PathQueriedInTrace H k tr i leaf path holds.
If findQueryInTrace recovers encPair encBits encBits (left, right), then
findPreimageInTrace recovers (left, right).
In a collision-free trace containing (encPair encBits encBits (left, right), digest),
findPreimageInTrace tr digest returns some (left, right).
Extract the leaf committed at position i of a depth-d Merkle tree with root rt from the
query-answer trace tr: walk d internal levels down from rt to the leaf digest, then invert
the leaf hash in tr.
If extractNodeFromTrace tr d rt i = some digest, then digest is either rt (when d = 0)
or one of unframe p.1, dropFrame p.1 for some entry p ∈ tr.
Prepending (q, ans) to tr leaves extractNodeFromTrace at rt unchanged whenever
ans ≠ rt and ans does not equal unframe p.1 or dropFrame p.1 for any p ∈ tr.
Prepending (q, ans) to tr leaves extractLeafFromTrace at rt unchanged whenever
ans ≠ rt and ans does not equal unframe p.1 or dropFrame p.1 for any p ∈ tr.
Prepending (q, ans) to tr leaves extractTableFromTrace at rt unchanged whenever
ans ≠ rt and ans does not equal unframe p.1 or dropFrame p.1 for any p ∈ tr.
Structure of merkleInputs and consistency of trace extraction #
Appending one sibling at the top of path prepends the top internal-node hash input to
merkleInputs H k leaf i path.
Recomputing the root along path ++ [sibling] hashes the pair of merkleRootOfPath on path
and sibling, ordered by bit path.length of i.
If findQueryInTrace tr (H k q) = some q for every hash input q along (leaf, i, path),
then extractNodeFromTrace from the recomputed root recovers the leaf digest some (H k leaf).
If findQueryInTrace tr (H k q) = some q for every hash input q along (leaf, i, path),
then extractLeafFromTrace from the recomputed root recovers some leaf.
Trace extraction consistency for merkleRootOfPath: in a collision-free trace containing
all hash steps of (leaf, i, path), extractLeafFromTrace at merkleRootOfPath H k leaf i path
returns some leaf.
Main consistency theorem (Chiesa–Yogev Lemma 18.5.7): if tr is collision-free and
contains all hash evaluations along an opening (leaf, path) of position i accepted by
merkleVerify H k d rt i leaf path, then extractLeafFromTrace tr d rt i = some leaf.
Under the hypotheses of extractLeafFromTrace_eq_some_of_merkleVerify, position i of the
extracted table extractTableFromTrace tr d rt defaultLeaf equals leaf.
Indexed form of getD_extractTableFromTrace_eq_of_merkleVerify.
Any two openings of the same position i accepted against rt at depth d whose hash paths
are recorded in a collision-free trace tr must open to the same leaf.
Dual collision extraction from trace disagreement #
Deterministically extract a hash collision from tr when an opening (leaf, path) at position
i disagrees with extractLeafFromTrace: find the first hash input q in
merkleInputs H k leaf i path whose digest H k q is inverted by findQueryInTrace tr to a
different query.
Dual collision extraction: if tr is consistent with H k and contains all hash steps of
an opening (leaf, path) accepted by merkleVerify H k d rt i leaf path, yet
extractLeafFromTrace tr d rt i ≠ some leaf, then extractTraceCollision H k tr i leaf path
returns two distinct queries in tr with the same hash under H k.
Collision-game form of extractTraceCollision_spec: when an accepted opening whose path is
in tr disagrees with extractLeafFromTrace, extractTraceCollision produces a valid collision
for isCollision H (fun _ _ => true) n k.
Existential form of extractTraceCollision_spec: if an accepted opening with all hash steps in
tr disagrees with extractLeafFromTrace, then tr contains two distinct queries with the same
hash under H k.
Random-oracle collision and preimage probability bounds #
Preimage / target-hitting union bound: a uniform m-bit digest lands in a list targets
of candidate digests with probability at most targets.length * (1 / 2 ^ m).
Adding a freshly sampled (q, ans) to a collision-free trace tr violates
TraceCollisionFree only if ans hits one of the digests already recorded in tr.map Prod.snd.
Single-step collision bound for a lazy random oracle: from a collision-free trace tr,
one call to memoize (fun _ => BitString.uniformList m) q tr produces a trace with a collision
with probability at most tr.length * (1 / 2 ^ m).
Each call to memoize increases the trace length by at most one.
Accumulated collision bound for a query-bounded ROM program: any OracleComp program
making at most Q queries to a lazy uniform m-bit random oracle starting from the empty trace
produces a collision in its final trace with probability at most Q * (Q * (1 / 2 ^ m)).
If tr has no duplicate keys, then tr is consistent with the canonical lookup function
fun q => (tr.lookup q).getD defaultDigest.
A single call to memoize records (q, ans) in the output trace, preserves existing entries,
keeps keys Nodup, and preserves support membership in dist.
Polynomial-time certificates for straight-line trace extraction #
Searching a Merkle trace for a digest takes polynomial time.
Inverting an internal-node digest in a Merkle trace takes polynomial time.
Walking a fixed number of levels d down from rt in a Merkle trace takes polynomial time.
Extracting a leaf at a fixed depth d from a Merkle trace takes polynomial time.
Extracting the full 2 ^ d-entry leaf table at a fixed depth d from a Merkle trace takes
polynomial time.
Extracting a collision from a Merkle trace when an opening disagrees with trace extraction takes polynomial time.
Checking TraceConsistentWith (H (k a)) (tr a) takes polynomial time.
Checking PathQueriedInTrace H (k a) (tr a) (i a) (leaf a) (path a) takes polynomial time.