Merkle trees as oracle programs #
merkleRootProg, merklePathProg and merkleVerifyProg lift the binary Merkle tree operations
merkleRoot, merklePath and merkleVerify (CslibFrontier.Crypto.Computational.MerkleTree,
CslibFrontier.Crypto.Computational.MerkleTree.Binding) to oracle programs over the unkeyed hash
interface MerkleHashSpec (List Bool → List Bool). Random-oracle constructions such as Micali's
computationally sound proofs (CslibFrontier.Crypto.Computational.Kilian.Micali) and the BCS
transformation (CslibFrontier.Crypto.Protocols.BCS.ROM) build their provers and verifiers from
these programs.
Evaluating the programs against a deterministic hash h with OracleComp.evalPure h reproduces
the pure operations at fun _ => h with the empty key (evalPure_merkleRootProg,
evalPure_merklePathProg, evalPure_merkleVerifyProg). Like merkleVerify, merkleVerifyProg
accepts only paths whose labels have the length of the root. Under a shared lazy random oracle
whose answers all have one length, every honest opening verifies with probability one
(merkleVerifyProg_merklePathProg). Under the memoized random oracle memoize dist, a
verification makes at most path.length + 1 queries and records every hash step of the checked
path in the final trace, as straight-line extraction
(CslibFrontier.Crypto.Computational.MerkleTree.ROMExtract) requires.
Main definitions #
Cslib.Crypto.MerkleHashSpec: the oracle interface of an unkeyed hashList Bool → List Bool.Cslib.Crypto.merkleRootProg,Cslib.Crypto.merklePathProg,Cslib.Crypto.merkleVerifyProg: oracle-program Merkle commitment, opening and verification.
Main results #
Cslib.Crypto.evalPure_merkleRootProg,Cslib.Crypto.evalPure_merklePathProg,Cslib.Crypto.evalPure_merkleVerifyProg: simulation bymerkleRoot,merklePathandmerkleVerify.Cslib.Crypto.evalPure_merkleVerifyProg_merklePathProg,Cslib.Crypto.merkleVerifyProg_merklePathProg: opening completeness under deterministic and lazy random oracles.Cslib.Crypto.isQueryBounded_merkleVerifyProg: the query bound of a verification.Cslib.Crypto.mem_support_run_memoize_invariant: the trace invariant of memoized runs.Cslib.Crypto.pathQueriedInTrace_of_mem_support_merkleVerifyProg,Cslib.Crypto.pathQueriedInTrace_of_mem_support_mapM_merkleVerifyProg: memoized verifications record the hash steps of every checked path.
Oracle-program Merkle tree #
Oracle-program computation of leaf-level labels in a Merkle tree, hashing each leaf and
padding to 2 ^ Nat.clog 2 leaves.length leaves with the empty word [].
Oracle-program computation of one parent layer in a Merkle tree.
Oracle-program computation of level j of the Merkle tree over leaves.
Oracle-program computation of the Merkle root of leaves.
Oracle-program computation of the sibling authentication path for position i.
One step of merkleInputsProg: hash the current head input and pair it with sibling.
Oracle-program Merkle path verification at depth d: checks path.length == d,
i < 2 ^ d, that every label has the length of root, and that the recomputed root equals
root, as merkleVerify does.
Simulation by a pure hash #
Completeness of merkleVerifyProg against merklePathProg (pure simulation form): for any
deterministic hash h whose digests all have ℓ bits and i < 2 ^ Nat.clog 2 leaves.length,
merkleVerifyProg accepts merkleRootProg leaves and merklePathProg leaves i.
Completeness of merkleVerifyProg against merklePathProg (lazy random-oracle form):
under a shared lazy random oracle RandomOracle.answer dist whose answers all have ℓ bits,
computing the root with merkleRootProg, opening position i < 2 ^ Nat.clog 2 leaves.length with
merklePathProg, and verifying with merkleVerifyProg returns true with probability 1.
Query bounds and memoized traces #
Multi-step invariant of memoize: running prog from tr produces tr' extending tr with
Nodup keys and supported values, and res = evalPure h prog for every h consistent with
tr'.
Running merkleVerifyProg d root i leaf path under memoize dist records every hash step of
merkleInputs in the final trace tr'.
Running a list of Merkle verifications under memoize dist records every hash step of each
checked opening in the final trace tr'. Item b is checked by check b, which verifies the
opening (leaf b, path b) at position pos b against root b (hcheck).