Merkle trees as authenticated data structures: verification and position binding #
Cslib.Crypto.merkleRoot hashes a list of leaves and Cslib.Crypto.merklePath opens one position.
This module adds the verifier and the security notion of an authenticated data structure scheme
([BS23], Section 8.9.1): a verifier merkleVerify with completeness, binding and a
polynomial-time certificate, the game of Attack Game 8.2, and Theorem 8.8: under collision
resistance of the hash on its domain, Merkle trees are position binding, with no loss.
- The verifier.
merkleVerify H k d root i leaf pathaccepts whenpathhasdlabels,i < 2 ^ d, every label has the length ofroot, and the root recomputed fromleafat positionialongpathisroot(theVof [BS23], Definition 8.3). The first two are the checks that the module documentation ofCslibFrontier.Crypto.Computational.MerkleTreerequires of a verifier, under "What a verifier must check"; without them binding fails. The third makes the path a list of digests, as a Merkle proof is in the source (Section 8.9, p. 321); without it, binding needs collision resistance beyond the hash's domain. Honest openings are accepted when all digests ofH khave one length (merkleVerify_merklePath,merkleVerify_merklePath_of_clog_eq), the correctness requirement of Definition 8.3. - Binding of the verifier. Two openings of one position to different leaves, both accepted at
the same depth, give a collision of
H k, found byextractMerkleCollision(isCollision_of_merkleVerify). When the leaves lie in a leaf space and the digests ofH khavenbits, the collision lies in the hash's domainmerkleHashDomain leafSpace n: the leaf space and the pairs ofn-bit digests, the source'sX ∪ Y²(Section 8.9, p. 320) (isCollision_merkleHashDomain_of_merkleVerify). - The game. In
merkleBindingGamethe adversary receives the security parameter and a uniform keyk, and outputs a root, a position and twoMerkleOpenings (MerkleBindingOutput). It wins when both leaves lie in the leaf space, both openings are accepted at the depth of the first path, and the leaves differ (merkleBreaksBinding).MerklePositionBinding H leafSpaceasks that every uniform strict PPT adversary win with negligible probability. - The reduction.
merkleCollisionFinderruns the adversary and appliesextractMerkleCollisionto its two openings. Every win yields a collision on the hash's domain, so the binding advantage is at most the collision advantage at every parameter (succProbability_merkleBindingGame_le), and the reduction is strict PPT (isPPT_merkleCollisionFinder). Hence collision resistance ofHonmerkleHashDomain leafSpacegives position binding (CollisionResistantOn.merklePositionBinding, Theorem 8.8). Collision resistance on all words implies it (merklePositionBinding_of_hashFamily).
Differences from [BS23]. Attack Game 8.2 is stated for a scheme over (X^n, Y)
with a fixed number n of items; here:
- the hash is a keyed family with a uniform
n-bit key, and adversaries are uniform strict PPT programs, as inCollisionResistant; footnote 1 on p. 290 identifies a random key given to the adversary with the source's system parameter; - digests have exactly
nbits, soY = {0, 1}ⁿ; - the leaf space is any predicate on words, of which the source's finite, efficiently recognizable leaf spaces of polynomially bounded words (Definition 2.9, p. 30) are instances;
- the adversary chooses the depth
d, the length of its first path, and must open both leaves at that depth, which makes the game stronger than one with a fixed depth; - positions are
0 ≤ i < 2 ^ d, the padding positions included, rather than1 ≤ i ≤ n; - the adversary writes its position in unary (
encMerkleBindingOutput), so the game covers polynomially bounded positions: enough for trees with polynomially many leaves, but not for trees whose leaves are indexed by superpolynomially many positions.
Kilian's construction. Kilian's succinct arguments commit to a PCP proof with a hash tree and
open the queried positions (Barak and Goldreich, Construction 3.4, steps
P1.3 and V3). That tree differs from this one, which is [BS23]'s Figure 8.12: its leaf
labels are the proof bits themselves, not their hashes, and an internal label hashes the plain
concatenation ℓ_γ0 ℓ_γ1 of its children's labels, not their encPair pairing. Its prover sends
both child labels at every level of a path rather than only the siblings, and the verifier checks
the same hash equations along the path. Barak and Goldreich's hashing family resists non-uniform
circuits.
Main definitions #
Cslib.Crypto.merkleVerify: accepting an opening at a given depth.Cslib.Crypto.MerkleOpening,Cslib.Crypto.MerkleOpening.verify,Cslib.Crypto.encMerkleOpening: an opening as a record of a leaf and its path, its verifier for leaves under an encoding into bit strings, and the encoding of openings with bit-string leaves.Cslib.Crypto.merkleHashDomain: the domainX ∪ Y²of the tree's hash.Cslib.Crypto.MerkleBindingOutput,Cslib.Crypto.encMerkleBindingOutput,Cslib.Crypto.MerkleBindingAdversary: the adversary's output, its encoding (the grouped tuple(root, position), first, second), and adversaries.Cslib.Crypto.merkleBreaksBinding,Cslib.Crypto.merkleBindingGame,Cslib.Crypto.MerklePositionBinding: the position-binding game and security notion.Cslib.Crypto.merkleCollisionFinder: the reduction to collision finding.
Main results #
Cslib.Crypto.merkleVerify_merklePath,Cslib.Crypto.merkleVerify_merklePath_of_clog_eq: honest openings are accepted.Cslib.Crypto.length_of_mem_merkleLevel,Cslib.Crypto.length_merkleRoot,Cslib.Crypto.length_of_mem_merklePath,Cslib.Crypto.length_le_of_mem_merklePath: tree nodes, the root and honest labels are digests, and the labels of any opening are short.Cslib.Crypto.computableInPolyTime_merkleVerify: verification takes polynomial time.Cslib.Crypto.isCollision_of_merkleVerify,Cslib.Crypto.isCollision_of_merkleVerify_merklePath,Cslib.Crypto.isCollision_merkleHashDomain_of_merkleVerify: two accepted openings of one position to different leaves yield a collision, on the hash's domain when the leaves lie in the leaf space.Cslib.Crypto.isCollision_of_merkleBreaksBinding,Cslib.Crypto.succProbability_merkleBindingGame_le,Cslib.Crypto.isPPT_merkleCollisionFinder: the certified reduction, with no loss.Cslib.Crypto.MerklePositionBinding.negligible,Cslib.Crypto.MerklePositionBinding.of_negligible: position binding as negligible success.Cslib.Crypto.CollisionResistantOn.merklePositionBinding: [BS23], Theorem 8.8.Cslib.Crypto.merklePositionBinding_of_hashFamily: the same under collision resistance on all words.
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Definition 2.9, footnote 1 on p. 290, Section 8.9, and Section 8.9.1 with Definitions 8.3 and 8.4, Attack Game 8.2 and Theorem 8.8.
- B. Barak, O. Goldreich, Universal Arguments and their Applications, Construction 3.4.
Verifying openings #
Accept path as an opening of position i of a depth-d tree with root root to leaf:
the path has d labels, i < 2 ^ d, every label has the length of root, and the recomputed
root is root. This is the verifier V of the Merkle tree as an authenticated data structure
([BS23], Definition 8.3), with the depth as an explicit argument. The length check
makes the path a list of digests, as a Merkle proof is in the source (Section 8.9, p. 321): an
accepted root is a digest, so the labels are too.
Accept the opening o of position i of a depth-d tree with root root, whose leaves are
the encodings encLeaf of the claimed values (merkleVerify on encLeaf o.leaf).
The encoding of an opening with bit-string leaves: the leaf, then the path.
Every node of the tree has ℓ bits when every digest of H k does.
The labels of an honest authentication path have ℓ bits when every digest of H k does:
below the root, every sibling of a position inside the tree is a node of the tree.
Honest openings are accepted: when every digest of H k has the same length, every
position i < 2 ^ Nat.clog 2 leaves.length of the tree over leaves, opened by its
authentication path, is accepted against the root (the correctness requirement of
[BS23], Definition 8.3).
Honest openings are accepted at any depth d equal to the tree's depth, for instance
d = Nat.clog 2 N for N leaves, when every digest of H k has the same length.
Openings are short: the labels of an authentication path have at most k.length bits
(a sibling outside the tree reads as []), so an opening of the tree over leaves has at most
Nat.clog 2 leaves.length * k.length bits of labels.
Binding of the verifier: two openings of position i to different leaves, both accepted
against root at depth d, contain a collision of H k, which extractMerkleCollision finds.
The length check makes the two paths equally long, as isCollision_extractMerkleCollision
requires.
Binding against an honest tree: an opening of position i of the tree over leaves,
accepted against its root at its depth, to a leaf other than leaf i, together with the honest
path of i, contains a collision of H k. Unlike isCollision_of_merkleVerify, this needs no
hypothesis on the lengths of the digests of H k.
The domain of the hash of a Merkle tree with leaf space leafSpace, at parameter n: the
leaves x with leafSpace n x, and the pairs of n-bit digests (isDigestPair n). This is
X ∪ Y² for Y = {0, 1}ⁿ in [BS23], Section 8.9 (p. 320): "The input to h is either
a single element in X, or a pair of elements in Y."
Binding of the verifier on the hash's domain: two openings of position i to different
leaves of leafSpace n, both accepted against root at depth d, contain a collision of H k
on merkleHashDomain leafSpace at n, when every digest of H k has n bits. The verifier's
length check makes every label a digest, so the collision lies in the leaf space or among the
pairs of digests.
Verifying an opening takes polynomial time: the key, the depth in unary, the root, the position in unary, the leaf and the path.
Position binding #
The encoding of MerkleBindingOutput: the root and the position as a pair, then the two
openings, which is the grouping of the tuple this record replaced. Bit strings are encoded as
themselves and the position in unary, as in computableInPolyTime_extractMerkleCollision, so an
efficient adversary outputs only polynomially bounded positions.
A binding output assembled from polynomial-time fields is polynomial-time.
A position-binding adversary receives the unary security parameter n and the hash key, and
outputs a root, a position and two openings.
out breaks position binding under the key k at parameter n: both leaves lie in the leaf
space leafSpace n, both openings are accepted at the same position of the same root, at the
depth of the first path, and the leaves differ.
The position-binding experiment ([BS23], Attack Game 8.2, p. 324, for a keyed hash
and leaf space leafSpace): sample a uniform n-bit key k, run the adversary on (n, k), and
accept when its output breaks binding under k at n.
Position binding of Merkle trees over H with leaf space leafSpace, a notion novel to this
library: every uniform strict PPT adversary breaks binding with negligible probability. As in
[BS23], Definition 8.4 and Attack Game 8.2 (p. 324), the two leaves lie in the leaf
space and merkleVerify accepts only paths of digests. It is stronger than Definition 8.4 in one
respect: the adversary chooses the depth of the tree, where the source's scheme has a fixed number
of leaves. It follows from collision resistance of H on merkleHashDomain leafSpace, the
assumption of Theorem 8.8 (CollisionResistantOn.merklePositionBinding). Adversaries write
positions in unary, so this covers polynomially bounded positions.
The collision finder built from a position-binding adversary: run it, and extract a collision
from its two openings with extractMerkleCollision.
A binding break yields a collision on the hash's domain: if out breaks position binding
under an n-bit key k, and H k returns n-bit digests, then extractMerkleCollision finds
two different words of merkleHashDomain leafSpace n with the same hash under k.
The reduction loses nothing: at every security parameter, a position-binding adversary
succeeds at most as often as its collision finder finds a collision on the hash's domain, when
H k returns k.length-bit digests.
The reduction is efficient: the collision finder of a strict PPT binding adversary is
strict PPT, for a polynomial-time H that returns k.length bits.
Position binding gives negligible success probability to every strict PPT adversary.
Establish position binding by bounding every strict PPT adversary's success probability.
Merkle trees are position binding under collision resistance of the hash on its domain
([BS23], Theorem 8.8, Section 8.9.1, p. 324): if H is collision resistant on the
leaf space and the pairs of digests (merkleHashDomain leafSpace, the source's X ∪ Y²,
Section 8.9, p. 320), then no uniform strict PPT adversary opens a position of a Merkle tree over
H to two different leaves of leafSpace except with negligible probability. H is a
polynomial-time keyed hash with digests of the key's length.
This is Theorem 8.8 for keyed hashes and uniform adversaries, with these differences:
- the hash takes a uniform
n-bit key, given to the adversary; footnote 1 on p. 290 says that this keyed form is the same as the source's system parameter; - digests have exactly
nbits, soY = {0, 1}ⁿ; - the leaf space is any predicate
leafSpace, of which the source's finite, efficiently recognizable and polynomially bounded leaf spaces (Definition 2.9, p. 30) are instances; - the adversary chooses the depth of the tree, which makes the game stronger than the source's,
whose scheme has a fixed number of leaves; positions are
0 ≤ i < 2 ^ d, the padding positions included, and written in unary, which covers polynomially bounded positions.
The reduction is merkleCollisionFinder, with no loss (succProbability_merkleBindingGame_le),
and it is strict PPT (isPPT_merkleCollisionFinder).
A collision-resistant HashFamily, collision resistant on all words, gives position binding
for every leaf space. This is CollisionResistantOn.merklePositionBinding through
CollisionResistantOn.mono: collision resistance on all words implies it on
merkleHashDomain leafSpace.