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
- a verifier who checks a receipt of Memo stones, Verified address or Bound notes: the receipt contains a txid;
- a wallet that finds its own transaction by its txid, also after a new signature;
- a light client that checks that a transaction is in a block, with the block headers and a Merkle path.
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
- Version 4 and older. For a v4 transaction, the txid is a double SHA-256 hash of the full encoding (ZIP 244). Thus, a person who changes a signature also changes the txid. A v4 txid is reliable only after the transaction is in a block.
- Signatures. A wallet signs a signature digest for each transparent input, each Sapling spend and each Orchard action (ZIP 244). For a transaction with transparent inputs, each signature digest also has the amounts and the scripts of the spent coins. For a transaction without transparent inputs, the signature digest is the txid.
- One network upgrade. The MMR of a header has the blocks since the last network upgrade only (ZIP 221).
- FlyClient. For a chain with fast difficulty changes, such as Zcash, the security of FlyClient is only heuristic. A deeper security analysis is necessary before light clients depend on FlyClient (ZIP 221).
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.
Wait