This section fixes the object a light client verifies, the Zcash block header, and the baseline procedure that verifies a chain of headers in full. It states the trust model of the light-client protocol specified for Zcash and the problem the volume solves, with each term of its solution defined in one clause and constructed in a later section.
A light client is a client that is not a full participant in the network of Zcash peers. It can send and receive payments, but does not store or validate a copy of the block chain (ZIP 221, “Terminology”).
The verifier of the FlyClient paper is a light client given the additional inputs fixed in Definition 4.16 (“Security and succinctness of chain proofs”, §4.4).
Byte strings and integers are related by the maps of the Ironwood
Guide, §“Fields, groups, and encodings”, Definition “Integer and byte
encodings”: the map I2LEOSP k sends an integer in
The CompactSize encoding of an integer
| CompactSize (v) := { I2LEOSP 8 (v) if 0 ≤ v ≤ 252, 0xFD ∥ I2LEOSP 16 (v) if 253 ≤ v ≤ 0xFFFF, 0xFE ∥ I2LEOSP 32 (v) if 0x10000 ≤ v ≤ 0xFFFFFFFF, 0xFF ∥ I2LEOSP 64 (v) if 0x100000000 ≤ v ≤ 0xFFFFFFFFFFFFFFFF, |
of length 1 , 3 , 5 or 9 bytes respectively. Only this encoding, the shortest, is valid for v : a byte string that decodes to v under one of the other three prefixes MUST be rejected (ZIP 204, “CompactSize”).
ZIP 204 has status Draft; the minimal-encoding rule binds block headers independently, through the protocol specification, §“Block Header Encoding and Consensus”, which requires the header field solutionSize to be encoded with the minimum number of bytes. That rule prevents a miner from testing several encodings of one Equihash solution against the difficulty filter.
The upgrade epochs delimited by the network upgrades of Definition 1.1 are fixed in “Upgrade epochs and epoch trees” (§6.2).
A Zcash block consists of a block header and a sequence of transactions. A block header hdr is the concatenation, in the following order, of the fields
| Bytes | Field | Content |
|---|---|---|
| 4 | nVersion | signed 32-bit integer; the consensus rules require nVersion ≥ 4 |
| 32 | hashPrevBlock | the block hash of the previous block |
| 32 | hashMerkleRoot | the root of the transaction Merkle tree over the identifiers of the block’s transactions, stated in “The authorising-data root” (§6.5) |
| 32 | commitment field | named as below |
| 4 | nTime | unsigned 32-bit integer, the block timestamp |
| 4 | nBits | unsigned 32-bit integer, an encoding of the target threshold |
| 32 | nNonce | 32 arbitrary bytes |
| 3 | solutionSize | CompactSize (1344) |
| 1344 | solution | an Equihash solution |
with integers encoded little-endian. The commitment field is named hashReserved before Sapling, hashFinalSaplingRoot in Sapling and Blossom, hashLightClientRoot in Heartwood and Canopy, and hashBlockCommitments from NU5; its value in each upgrade epoch is fixed in “The header consensus rules” (§6.7). The block hash of hdr is the 32 -byte string
| BlockHash (hdr) := SHA256d (hdr), SHA256d (x) := SHA256 (SHA256 (x)), |
taken over the whole header serialisation, solutionSize and
solution included, in internal byte order, the order in which the
hash function outputs its bytes. Let
| LEOS2IP 256 (BlockHash (hdr)) ≤ ToTarget (nBits) |
(protocol specification, §“Difficulty filter”). The consensus rules
further require, for a block at height η , that
The definition follows protocol specification, §“Block Header Encoding and Consensus” for the field table and its consensus rules, and ZIP 221, “Block header semantics and consensus rules” and ZIP 244 for the renaming of the commitment field. The hash SHA256d is registered in the Crypto Guide, §“The transparent layer’s hashes”. The Equihash condition is cited, not reconstructed: Consensus Guide, §“Equihash and the memoryless model”. The work of a block whose header carries nBits is
| work (hdr) := ⌊ 2 256 ToTarget (nBits) + 1 ⌋, |
and the total work ω (C) of a chain C is the sum of the work of its blocks; a node considers the valid chain of greatest total work to be best, breaking ties between leaf blocks in favour of the block received first (Consensus Guide, §“The block tree and the most-work rule”, and its subsection §“Work, and the best chain”; protocol specification, §“The Block Chain” and §“Definition of Work”).
The fixed-width fields of Definition 2.3 occupy
A claimed chain of length
linkage: for
proof of work: for
It rejects every chain that fails a check and accepts, among the rest, the chain C of greatest total work ω (C) , under the best-chain rule of the Consensus Guide, §“Work, and the best chain”.
The definition is that of ePrint 2019/226, Section 1, p. 2, instantiated
with the header checks of protocol specification, §“Block Header Encoding
and Consensus”. For a claimed chain of N blocks the client receives N
headers,
An SPV client checks neither the validity of transactions nor any consensus rule beyond those of the header, and therefore relies on the following assumption.
“The chain with the most PoW solutions follows the rules of the network and will eventually be accepted by the majority of miners.” (ePrint 2019/226, Section 1, p. 2, Assumption 1.)
ZIP 307 (Draft) specifies a light-client protocol in which a light client obtains, from a Zcash node and a proxy, compact blocks: per-block messages that may carry the block header. The trust model is stated in ZIP 307, “Security Model”: the node and proxy combination is assumed to be “honest but curious” and “is trusted to provide a correct view of the current best chain state and to faithfully transmit queries and responses”.
ZIP 307, “Block header validation” describes, as a proposed enhancement that the ZIP records as only partially implemented (only check (Z2) is made), checks of the SPV kind on each compact block that carries a header. With the fields named as in Definition 2.3, the checks are:
the field nVersion is at least the minimum block version;
the field hashPrevBlock equals the block hash of the previous compact block;
the Equihash solution is valid;
the target ToTarget (nBits) is non-zero and at most the proof-of-work limit PoWLimit (protocol specification, §“Constants”);
when the last 27 compact blocks all carry headers, the field nBits is correct under the difficulty-adjustment rule;
the block hash, read as a little-endian integer, is at most ToTarget (nBits) .
In that proposal, a compact block that fails a check MUST be discarded. The
count 27 of check (Z5) does not suffice. Let W be the averaging window of
protocol specification, §“Difficulty adjustment”, 17 blocks, and 102 from
NU7 (ZIP 218, “Averaging window”). The value ThresholdBits (η)
reads the fields nBits of heights
Of the trust that ZIP 307 places in the node and proxy, a FlyClient verifier would replace only the trust in which header chain carries the most work, under Assumption 4.8 (“The (c, L) -adversary”). It would replace the linear header checks by the logarithmic sampling of “The FlyClient protocol” (§5); it does not replace faithful transmission of queries and of compact-block contents. Such a verifier is designed but unspecified in the sense of Definition 1.3; its status is fixed in “A Zcash verifier” (§7.4).
The problem is the following. Under the SPV assumption (Assumption 2.5), strengthened quantitatively as Assumption 4.8 in “The (c, L) -adversary” (§4.3), a light client is to accept the head of the chain of greatest total work after communication sublinear in the chain length N . The inputs and the chain to be selected are those of Definition 2.4; the assumption is strengthened to Assumption 4.8, the selection holds except with a failure probability fixed in “The FlyClient protocol” (§5), and the communication falls from Θ (N) to sublinear.
A client that does not check every proof of work “can be tricked into accepting an invalid chain by a malicious prover who can precompute a sufficiently-long chain using its limited computational power” (ePrint 2019/226, Section 1, p. 3); the adversary is fixed in “The FlyClient security model” (§4).
The solution uses four objects. A Merkle mountain range is a binary hash tree over a sequence that admits appending a leaf without changing its peaks or any node beneath them (“Merkle mountain ranges”, §3). A header chain commitment is a root, carried in every header after the genesis header, of such a range over all blocks strictly before that header (“Header chain commitments and per-sample checks”, §5.1). A work-weighted sample is a block drawn at a random point of cumulative work and checked against the commitment of the head (“The sampling distribution”, §5.4). A suffix of the chain is downloaded and checked in full, its extent fixed in the same subsection. FlyClient is the protocol that verifies a proof-of-work chain by drawing logarithmically many such samples and checking each against the commitment of the head (ePrint 2019/226, Section 1). The commitment of the paper covers the chain from the genesis block, whereas the commitment of ZIP 221 covers one upgrade epoch: the blocks from the activation height of the preceding network upgrade up to the committing block, exclusive (ZIP 221, “Specification”; “Upgrade epochs and epoch trees”, §6.2).