Applied Zcash

Basic

Transaction IDs

A receipt contains the ID of a transaction, the txid. For a v5 or v6 transaction, the txid is a digest of the effecting data. The authorizing data is in a separate digest.

Use

Mechanism

The txid

For v5 transactions, the authorizing data is the signatures, the proofs and the scripts of transparent inputs. The effecting data is all the other data.

The txid is the root of a tree of BLAKE2b-256 digests (ZIP 244). Each node has its own personalization string. Each pool has its own branch:

txid
├── header_digest        version, version group ID, consensus branch ID, lock time, expiry height
├── transparent_digest   outpoints, sequence numbers, outputs
├── sapling_digest       spends, outputs, value balance
└── orchard_digest       actions, flags, value balance, anchor

The txid has no signatures and no proofs. Thus, a person who changes a signature or a proof cannot change the txid. The consensus branch ID is in the personalization of the root. Thus, a transaction has a different txid on each consensus branch.

Libraries and explorers show the txid with its bytes in reverse order, as in the zcash_protocol crate. Compare a txid only with a txid in the same byte order.

The authorizing data digest

The authorizing data is in a second tree:

auth_digest
├── transparent_scripts_digest   the script of each transparent input
├── sapling_auth_digest          proofs, spend signatures, binding signature
└── orchard_auth_digest          proofs, spend signatures, binding signature

The pair of the txid and the authorizing data digest is a commitment to all the data of the transaction.

Version 6

Since NU6.3, each tree of a v6 transaction also has an Ironwood branch (ZIP 229). In version 6, the anchors are authorizing data. In version 5, they are effecting data. Thus, a wallet can update the anchor and the proofs of a v6 transaction. The txid stays the same.

Proof of inclusion

Each block header has the root hashMerkleRoot of a Merkle tree of the txids of the block. With a Merkle path from a txid to this root, a verifier checks that the transaction is in the block.

Since NU5, the header field hashBlockCommitments is a digest of two roots and 32 zero bytes (ZIP 244). hashAuthDataRoot is the root of a Merkle tree of the authorizing data digests of the block. hashLightClientRoot is the root of a Merkle Mountain Range (MMR) of the earlier blocks (ZIP 221).

With the MMR and the FlyClient protocol, a light client checks a chain and the inclusion of a block. The client needs a logarithmic number of headers only. The check is probabilistic (ZIP 221).

Limits

Demo: the digests of a v5 transaction

The demo uses the blake2b_simd crate, compiled to WebAssembly. It reads a v5 transaction and calculates the main nodes of the two trees. The sample transaction is the fourth ZIP 244 test vector. Its txid and its authorizing data digest are the same as in the test vector.

Select a field and change one byte. The demo marks the digests with a new value. The demo reads v5 transactions only.

Demo

Wait

txid tree

Authorizing data tree

Change this page on GitHub