Skip to content
zips.tools

ZIP 248

Extensible Transaction Format

  • Draft
Proposal metadata
ID
248
Status
Draft
Category
Consensus / Wallet
Created
2025-12-17
License
MIT
Contents
  1. Sighash Variants
  2. Digest Algorithms
  3. Implications for Wallets
  4. Bundle Definitions

The means of authorization differs between transparent inputs, inputs to Sprout JoinSplit transfers, and Sapling Spend transfers or Orchard Action transfers. For a given pre-v7 transaction version the same SIGHASH transaction hash algorithm is used. For v7 transactions, the algorithm is selected for each signer as specified in ZIP 248, 'Sighash Variants'.

In the same section, after:

[NU6.3 onward] The SIGHASH algorithm used for version 6 transactions is defined in ZIP 229.

add:

The SIGHASH algorithms used for v7 transactions are defined in ZIP 248.

In § 4.13 'Balance and Binding Signature (Sapling)',9 change:

Let SigHash\mathsf{SigHash} be the SIGHASH transaction hash for the appropriate transaction version, not associated with an input, using the SIGHASH type SIGHASH_ALL\mathsf{SIGHASH\_ALL}. This is defined in ZIP 243 for a version 4 transaction, or in ZIP 244 for a version 5 transaction, or in ZIP 229 for a version 6 transaction.

to:

For a pre-v7 transaction, let SigHash\mathsf{SigHash} be the SIGHASH transaction hash for the appropriate transaction version, not associated with an input, using the SIGHASH type SIGHASH_ALL\mathsf{SIGHASH\_ALL}. This is defined in ZIP 243 for a version 4 transaction, or in ZIP 244 for a version 5 transaction, or in ZIP 229 for a version 6 transaction.

For a v7 transaction, let SigHash\mathsf{SigHash} be the digest selected by the binding signature's sighashInfo, as specified in ZIP 248, 'Sapling Sighash Algorithms'.

In § 4.14 'Balance and Binding Signature (Orchard)',10 change:

Let SigHash\mathsf{SigHash} be the SIGHASH transaction hash for the appropriate transaction version, not associated with an input, using the SIGHASH type SIGHASH_ALL\mathsf{SIGHASH\_ALL}. This is defined in ZIP 244 for a version 5 transaction, or in ZIP 229 for a version 6 transaction.

to:

For a pre-v7 transaction, let SigHash\mathsf{SigHash} be the SIGHASH transaction hash for the appropriate transaction version, not associated with an input, using the SIGHASH type SIGHASH_ALL\mathsf{SIGHASH\_ALL}. This is defined in ZIP 244 for a version 5 transaction, or in ZIP 229 for a version 6 transaction.

For a v7 transaction, let SigHash\mathsf{SigHash} be the digest selected by the sighashInfo of the binding signature for this bundle, as specified in ZIP 248, 'Orchard Protocol Sighash Algorithms'.

In § 4.15 'Spend Authorization Signature (Sapling and Orchard)', 14 change:

Let SigHash\mathsf{SigHash} be the SIGHASH transaction hash as defined in ZIP 243 or as defined in ZIP 244 modified by ZIP 225, not associated with an input, using the SIGHASH type SIGHASH_ALL\mathsf{SIGHASH\_ALL}.

to:

For a pre-v7 transaction, let SigHash\mathsf{SigHash} be the SIGHASH transaction hash as defined in ZIP 243 or as defined in ZIP 244 modified by ZIP 225, not associated with an input, using the SIGHASH type SIGHASH_ALL\mathsf{SIGHASH\_ALL}.

For a v7 transaction, let SigHash\mathsf{SigHash} be the digest selected by this spend authorization signature's sighashInfo, as specified in ZIP 248, 'Sapling Sighash Algorithms' for Sapling signatures or ZIP 248, 'Orchard Protocol Sighash Algorithms' for Orchard and Ironwood signatures.

Coinbase identification and metadata

In § 3.11 'Coinbase Transactions',7 change:

A transaction that has a single transparent input with a null prevout field, is called a coinbase transaction.

to:

A pre-v7 transaction that has a single transparent input with a null prevout field is called a coinbase transaction. A v7 transaction is a coinbase transaction if and only if its mEffectBundles map contains an entry with bundleType = CoinbaseBundleId.

In § 7.1.2 'Transaction Consensus Rules',12 change the paragraph starting with:

A coinbase transaction for a block at block height greater than 0

to instead start with:

A pre-v7 coinbase transaction for a block at block height greater than 0

In the same section, change:

A coinbase transaction script MUST have length in {2..100}\{2 .. 100\} bytes.

to:

A pre-v7 coinbase transaction script MUST have length in {2..100}\{2 .. 100\} bytes.

A v7 coinbase transaction has no coinbase script. Its block height and miner-chosen data are encoded in the coinbase bundle.

Shielded balance encoding

In § 4.13 'Balance and Binding Signature (Sapling)',9 change:

vSaplingPoolBalance\mathsf{v}^{\textit{SaplingPoolBalance}} is encoded in a transaction as the field valueBalanceSapling. For a v4 transaction, vSaplingPoolBalance\mathsf{v}^{\textit{SaplingPoolBalance}} is always explicitly encoded. For v5, vSaplingPoolBalance\mathsf{v}^{\textit{SaplingPoolBalance}} is implicitly zero if the transaction has no Spend descriptions or Output descriptions. Transaction fields are described in § 7.1 'Transaction Encoding and Consensus'.

to:

For a pre-v7 transaction, vSaplingPoolBalance\mathsf{v}^{\textit{SaplingPoolBalance}} is encoded in the transaction as the field valueBalanceSapling. For a v4 transaction, vSaplingPoolBalance\mathsf{v}^{\textit{SaplingPoolBalance}} is always explicitly encoded. For v5, vSaplingPoolBalance\mathsf{v}^{\textit{SaplingPoolBalance}} is implicitly zero if the transaction has no Spend descriptions or Output descriptions. Transaction fields are described in § 7.1 'Transaction Encoding and Consensus'.

For a v7 transaction, vSaplingPoolBalance\mathsf{v}^{\textit{SaplingPoolBalance}} is obtained as specified in ZIP 248, 'Shielded balancing values'.

In § 4.14 'Balance and Binding Signature (Orchard)',10 using pool\textit{pool} as defined there, change:

vpoolBalance\mathsf{v}^{\textit{poolBalance}} is encoded in a transaction as the field valueBalanceOrchard/Ironwood. If a transaction has no Action descriptions for pool\textit{pool}, vpoolBalance\mathsf{v}^{\textit{poolBalance}} is implicitly zero. Transaction fields are described in § 7.1 'Transaction Encoding and Consensus'.

to:

For a pre-v7 transaction, vpoolBalance\mathsf{v}^{\textit{poolBalance}} is encoded in the transaction as the field valueBalanceOrchard/Ironwood. If a pre-v7 transaction has no Action descriptions for pool\textit{pool}, vpoolBalance\mathsf{v}^{\textit{poolBalance}} is implicitly zero. Transaction fields are described in § 7.1 'Transaction Encoding and Consensus'.

For a v7 transaction, vpoolBalance\mathsf{v}^{\textit{poolBalance}} is obtained as specified in ZIP 248, 'Shielded balancing values'.

Shielded balance ranges

In § 7.1.2 'Transaction Consensus Rules',12 change:

  • [Sapling onward] valueBalanceSapling, if it exists, MUST be in the range {−MAX_MONEY .. MAX_MONEY}\{-\mathsf{MAX\_MONEY} \,..\, \mathsf{MAX\_MONEY}\}.
  • [NU5 onward] valueBalanceOrchard, if it exists, MUST be in the range {−MAX_MONEY .. MAX_MONEY}\{-\mathsf{MAX\_MONEY} \,..\, \mathsf{MAX\_MONEY}\}.
  • [NU6.3 onward] valueBalanceIronwood, if it exists, MUST be in the range {−MAX_MONEY .. MAX_MONEY}\{-\mathsf{MAX\_MONEY} \,..\, \mathsf{MAX\_MONEY}\}.
  • [NU6.3 onward] valueBalanceOrchard, if it exists, MUST be nonnegative.

to:

  • [Sapling onward] vSaplingPoolBalance\mathsf{v}^{\textit{SaplingPoolBalance}} MUST be in the range {−MAX_MONEY .. MAX_MONEY}\{-\mathsf{MAX\_MONEY} \,..\, \mathsf{MAX\_MONEY}\}.
  • [NU5 onward] vOrchardPoolBalance\mathsf{v}^{\textit{OrchardPoolBalance}} MUST be in the range {−MAX_MONEY .. MAX_MONEY}\{-\mathsf{MAX\_MONEY} \,..\, \mathsf{MAX\_MONEY}\}.
  • [NU6.3 onward] vIronwoodPoolBalance\mathsf{v}^{\textit{IronwoodPoolBalance}} MUST be in the range {−MAX_MONEY .. MAX_MONEY}\{-\mathsf{MAX\_MONEY} \,..\, \mathsf{MAX\_MONEY}\}.
  • [NU6.3 onward] vOrchardPoolBalance\mathsf{v}^{\textit{OrchardPoolBalance}} MUST be nonnegative.

Chain value pool balance definitions

In § 4.17 'Chain Value Pool Balances',11 change:

As defined in ZIP 209, the Sapling chain value pool balance for a given block chain is the negation of the sum of all valueBalanceSapling values for transactions in the chain.

to:

As defined in ZIP 209, the Sapling chain value pool balance for a given block chain is the negation of the sum of all vSaplingPoolBalance\mathsf{v}^{\textit{SaplingPoolBalance}} values for transactions in the chain.

In the same section, change:

Similarly to the Sapling chain value pool balance defined in ZIP 209, the Orchard chain value pool balance for a given block chain is the negation of the sum of all valueBalanceOrchard field values for transactions in the chain.

to:

Similarly to the Sapling chain value pool balance defined in ZIP 209, the Orchard chain value pool balance for a given block chain is the negation of the sum of all vOrchardPoolBalance\mathsf{v}^{\textit{OrchardPoolBalance}} values for transactions in the chain.

In the same section, change:

The Ironwood chain value pool balance for a given block chain is the negation of the sum of all valueBalanceIronwood field values for transactions in the block chain.

to:

The Ironwood chain value pool balance for a given block chain is the negation of the sum of all vIronwoodPoolBalance\mathsf{v}^{\textit{IronwoodPoolBalance}} values for transactions in the block chain.

Sighash Variants

This ZIP introduces sighash algorithm variants. Where previously each transaction version had a single associated sighash algorithm, going forward it is possible for signers to use any sighash algorithm within the closed set specified for a given transaction version (and made available in consensus via network upgrades).

The sighash variant is encoded as a single byte alongside any associated data that the sighash algorithm variant requires (for deterministically computing the digest):

sighashInfo = [sighashVariant] || associatedData

where associatedData is specific to the bundle it appears in.

The preimage of each signature digest MUST begin with the single-byte sighashVariant, to domain-separate the sighash algorithm variants.

Each bundle type defines the sighash algorithm variants available to its signers, the associatedData that each variant requires, and the digest that a signature using it commits to. Those definitions are given for the bundle types registered by this ZIP in Bundle Definitions.

Variant 0 is the "commit to all effecting data" sighash algorithm. Other variants can define different commitments, including partial commitments across bundles, within a given transaction version. Consensus rules choose the digest algorithm for each signer based on sighashVariant.

Sighash variant information is present alongside each signature in the authorizing data of each bundle.

Digest Algorithms

All digests are personalized BLAKE2b-256 hashes. In cases where no elements are available for hashing (for example, if there are no transparent transaction inputs), a personalized hash of the empty byte array will be used. The personalization string therefore provides domain separation for the hashes of even empty data fields.

The notation BLAKE2b-256(personalization_string, []) is used to refer to hashes constructed in this manner.

TxId Digest

A new transaction digest algorithm is defined that constructs the identifier for a v7 transaction from a tree of hashes. The overall structure of the hash is as follows:

txid_digest
├── header_digest
├── value_pool_deltas_digest
└── effects_bundles_digest
    ├─ (bundle_type_id || bundle_variant || transparent_effects_digest)
    ├─ (bundle_type_id || bundle_variant || coinbase_effects_digest)
    ├─ (bundle_type_id || bundle_variant || sapling_effects_digest)
    │   ├── sapling_spends_digest
    │   │   ├── sapling_spends_compact_digest
    │   │   └── sapling_spends_noncompact_digest
    │   └── sapling_outputs_digest
    │       ├── sapling_outputs_compact_digest
    │       ├── sapling_outputs_memos_digest
    │       └── sapling_outputs_noncompact_digest
    ├─ (bundle_type_id || bundle_variant || orchard_effects_digest)
    │   ├── orchard_actions_compact_digest
    │   ├── orchard_actions_memos_digest
    │   └── orchard_actions_noncompact_digest
    ├─ (bundle_type_id || bundle_variant || ironwood_effects_digest)
    │   ├── ironwood_actions_compact_digest
    │   ├── ironwood_actions_memos_digest
    │   └── ironwood_actions_noncompact_digest
    └─ (bundle_type_id || bundle_variant || unknown_bundle_effects_digest) ...

Each node written as snake_case in this tree is a BLAKE2b-256 hash of its children, initialized with a personalization string specific to that branch of the tree. Nodes that are not themselves digests are written in camelCase. In the specification below, nodes of the tree are presented in depth-first order.

txid_digest

A BLAKE2b-256 hash of the following values:

T.1: header_digest             (32-byte hash output)
T.2: value_pool_deltas_digest  (32-byte hash output)
T.3: effects_bundles_digest    (32-byte hash output)

The personalization field of this hash is set to:

"ZcashTxHash_" || CONSENSUS_BRANCH_ID

ZcashTxHash_ has 1 underscore character.

As in ZIP 24425, CONSENSUS_BRANCH_ID is the 4-byte little-endian encoding of the consensus branch ID for the epoch of the block containing the transaction.

T.1: header_digest

A BLAKE2b-256 hash of the following values:

T.1a: version             (4-byte little-endian version identifier including overwintered flag)
T.1b: nVersionGroupId    (4-byte little-endian version group identifier)
T.1c: nConsensusBranchId (4-byte little-endian consensus branch id)
T.1d: nExpiryHeight       (4-byte little-endian block height)

The personalization field of this hash is set to:

"ZTxIdHeadersH_v7"
T.2: value_pool_deltas_digest

A BLAKE2b-256 hash of the concatenated encodings of all entries in mValuePoolDeltas, in transaction order. For each entry, the following values are concatenated:

T.2a: bundleType    (compactSize encoding)
T.2b: bundleVariant (compactSize encoding)
T.2c: value         (8-byte signed little-endian)

The personalization field of this hash is set to:

"ZTxIdVPDeltaHash"

In the case that the transaction has no value pool delta entries, value_pool_deltas_digest is:

BLAKE2b-256("ZTxIdVPDeltaHash", [])
T.3: effects_bundles_digest

A BLAKE2b-256 hash of the concatenated tagged bundle effect digests for all bundles present in mEffectBundles, in transaction order. For each bundle, the following values are concatenated:

T.3a: bundleType            (compactSize encoding)
T.3b: bundleVariant         (compactSize encoding)
T.3c: bundle_effects_digest (32-byte hash output)

where bundle_effects_digest is the root hash of the bundle's effecting data tree, as defined for each bundle type in Bundle Definitions.

The personalization field of this hash is set to:

"ZTxIdEffBnd_Hash" (1 underscore character)

In the case that the transaction has no effect bundles, effects_bundles_digest is:

BLAKE2b-256("ZTxIdEffBnd_Hash", [])
Rationale for Per-Bundle Effects Digests
Click to show/hide

Each effecting bundle contributes a fixed-size digest to this hash. A wallet can therefore use a supplied digest for an unsupported bundle without parsing its internal structure, while computing the other bundle digests itself. The bundleType and bundleVariant tags remain committed to alongside each digest, and the header and complete value pool delta map remain separate commitments in the transaction identifier. This permits bundle-specific hash trees, including the subtrees used in compact representations, without requiring every receiving wallet to understand every bundle's hash tree.

Variant 0 Signature Digest

A new per-input transaction digest algorithm is defined that constructs a hash that may be signed by a transaction creator to commit to the effects of the transaction. This follows closely the algorithm from ZIP 24425.

The digest algorithm used for a given signature is determined by the sighashVariant from the signer's sighashInfo, as specified in the Sighash Variants section. For sighash variant 0 (the only variant currently defined for v7 transactions), the digest algorithm is as specified below. Future network upgrades may define additional sighash algorithm variants with divergent behavior.

All variant 0 signatures commit to the complete transaction effects, using the same commitment as the transaction identifier, and to the amounts and script public keys of all transparent inputs. These transaction-wide commitments are separate from the bundle-defined context of the signature being made:

signature_digest
├── sighashVariant
├── txid_digest
├── amounts_sig_digest
├── scriptpubkeys_sig_digest
├── bundleType
├── bundleVariant
└── signature_context
signature_digest

A BLAKE2b-256 hash of the following values:

S.1: sighashVariant            (1 byte, 0x00)
S.2: txid_digest               (32-byte hash output)
S.3: amounts_sig_digest        (32-byte hash output)
S.4: scriptpubkeys_sig_digest  (32-byte hash output)
S.5: bundleType                (compactSize encoding)
S.6: bundleVariant             (compactSize encoding)
S.7: signature_context         (bundle-defined byte string)

The personalization field of this hash is set to:

"ZcashSigHash_v7_" (2 underscore characters)

bundleType and bundleVariant identify the bundle containing the signature. signature_context is defined for that bundle type and variant in Bundle Definitions. It is the final field, with no additional length prefix.

Every signature uses the amounts_sig_digest and scriptpubkeys_sig_digest defined in Transparent Digests, independently of which bundle contains the signature.

Rationale for Variant 0 Commitments
Click to show/hide

The signature digest algorithms previously defined for Zcash have three distinct variants:

  • For v1 and v2 transactions, it followed the Bitcoin convention of using the "hash the transaction" transaction ID digest algorithm while including or omitting information as relevant for the transparent sighash kind.
  • For v3 and v4, a SegWit-style signature hash algorithm used a two-level hash: the outer digest was over commitments to the various different parts of the transaction, while the TxId was unaltered.
  • For v5 and v6, both the TxId and the sighash were tree commitments to the transaction data, with the sighash digest algorithm reusing as many of the inner commitments computed by the TxId digest as possible, but substituting in different digests where signature-relevant data was included or omitted.

All of these variants diverged from the TxId digest because of how the transparent sighash kinds carried over from Bitcoin were defined. Due to a combination of subtleties around the interpretation of the sighash kinds for transparent-only wallets being ported from Bitcoin, and the lack of equivalent information exposed by the shielded actions, the sighash kinds were not adapted to include equivalent logic on the shielded pools. Instead, they always acted as if the shielded components of a transaction were defined with SIGHASH_ALL. As a consequence, the sighash kinds are only effective in transparent-only transactions.

When transaction ID malleability was addressed for v5 transactions in ZIP 244 25, the TxId and sighash digest algorithms were defined such that if you were signing a transaction that contained no transparent information, you just signed the TxId. In addition to being more efficient (as TxIds are usually computed at parsing time and cached), it is clear that this has the property one expects for a signature that is committing to all of the effecting data in a transaction.

For this ZIP's variant 0 digest, we instead commit directly to the TxId in a wrapping digest; the additional signature-specific information that previously was committed in-situ with the effecting data is instead committed beside the TxId. This has the same overall binding property, while improving the efficiency for all shielded signatures as well as SIGHASH_ALL transparent signatures.

This simplicity and efficiency is only possible by dropping support for non SIGHASH_ALL transparent signatures from variant 0. This is justified for several reasons:

  • These transparent signatures can still be created on the network today with v5 or v6 transactions. There are no functionality changes to the transparent signing capabilities in transparent bundle variant 0.
  • The sighash variants introduced in this ZIP provide an equivalent mechanism that does not inherit the semantic baggage of the transparent sighash kinds. A future ZIP could define a sighash variant that provides equivalent functionality, while potentially also expanding it to compatible shielded logic, if demand for such functionality in v7 transactions appears.
    • One difference between the transparent sighash kinds and sighash variants is that a sighash variant is specified at a per-input level, whereas sighash kinds are specified at a per-signature level. The latter can be leveraged in P2SH scripts, albeit being tricky to reason about. However, this difference can be eliminated by either defining the future sighash variant to use the sighash kind bytes that remain embedded into scripts, or by leveraging the associatedData field to store any additional per-signature metadata necessary for the variant.
  • TODO collect data about observed usage of non SIGHASH_ALL sighash kinds.

The additional transaction-wide amount and script commitments preserve the hardware-wallet protections of ZIP 244.25 The explicit fee defined in ZIP 200229 allows a signer to display the committed fee without reconstructing it from input amounts. However, in a transaction with inputs from multiple parties, the signer must also be able to identify which inputs belong to it and their values. Committing to every input's amount and script public key prevents a host from obtaining signatures in separate sessions using inconsistent descriptions of the other inputs, even when those descriptions have the same total input value. All signers commit to these digests, including shielded signers. Their positional correspondence with the transparent inputs binds them to the previous-output references already committed to by the transaction identifier; they need not be adjacent to those references in the hash tree.

Each spend signature's context includes the zero-based index of the input being signed within its bundle's effecting-data array. This binds the signature to that position, even when another input uses the same authorization key. The bundle type and variant distinguish indices belonging to different bundles. Shielded binding signatures have an empty context, distinct from every spend-signature context.

The index is encoded as a fixed two-byte unsigned little-endian integer. The Sapling spend and Orchard protocol action counts are already constrained by consensus to be less than 2162^{16}.12 Each transparent input's effecting data occupies 40 bytes, so the 2,000,000-byte block size limit also bounds its index below 2162^{16}.5 No additional count limit is needed.

The transaction identifier and the two aggregate input digests can each be computed once per transaction and reused for every signature. The aggregate input digests require the referenced UTXO data, but their computation does not require changing or recomputing the transaction identifier. Implementations can also clone a BLAKE2b state containing the common prefix before appending the signature context, and can reuse the completed digest for multiple signatures authorizing the same input.

BLAKE2b processes 128-byte blocks. With the currently defined one-byte bundle type and variant encodings, the prefix through bundleVariant is 99 bytes. A shielded spend signature has a two-byte context, giving a 101-byte preimage; a shielded binding signature's empty context gives a 99-byte preimage. Both fit in one block. For a transparent input with a script public key of LL bytes, the preimage length is 149+CompactSizeLen(L)+L149 + \mathsf{CompactSizeLen}(L) + L bytes, where CompactSizeLen(L)\mathsf{CompactSizeLen}(L) is the length in bytes of the CompactSize encoding of LL. A 25-byte P2PKH script gives 175 bytes (47 bytes in the second block); a 23-byte P2SH script gives 173 bytes (45 bytes in the second block). The latter commits to the script public key, not the redeem script. The shared 99-byte prefix does not fill a block: the first block also contains the first 29 bytes of the input's prevout_hash. In general, each of these transparent digests therefore requires two compressions. Inputs spending outputs of the same previous transaction share the first block, allowing its non-final hash state to be reused. Longer scripts can require additional blocks. No transaction-wide input list or bundle effects need to be rehashed for each signature.

Authorizing Data Commitment

A transaction digest algorithm is defined that constructs a digest committing to the authorizing data of a transaction. The overall structure is:

auth_digest
└── auth_bundles_digest
    ├─ (bundle_type_id || bundle_variant || transparent_auth_digest)
    ├─ (bundle_type_id || bundle_variant || sapling_auth_digest)
    ├─ (bundle_type_id || bundle_variant || orchard_auth_digest)
    ├─ (bundle_type_id || bundle_variant || ironwood_auth_digest)
    └─ (bundle_type_id || bundle_variant || unknown_bundle_auth_digest) ...
auth_digest

A BLAKE2b-256 hash of the following value:

A.1: auth_bundles_digest (32-byte hash output)

The personalization field of this hash is set to:

"ZTxAuthHash_" || CONSENSUS_BRANCH_ID
A.1: auth_bundles_digest

A BLAKE2b-256 hash of the concatenated tagged bundle auth digests for all bundles present in mAuthBundles, in transaction order. For each bundle, the following values are concatenated:

A.1a: bundleType          (compactSize encoding)
A.1b: bundleVariant       (compactSize encoding)
A.1c: bundle_auth_digest  (32-byte hash output)

The personalization field of this hash is set to:

"ZTxAuthBnd__Hash" (2 underscore characters)

In the case that the transaction has no auth bundles, auth_bundles_digest is:

BLAKE2b-256("ZTxAuthBnd__Hash", [])

Implications for Wallets

Choice of transaction format when sending

When creating a transaction, a wallet SHOULD use the oldest transaction format that is valid at the height at which the transaction is expected to be mined, and that supports every protocol feature the transaction requires. A wallet SHOULD use the v7 transaction format only for transactions that require a feature that no older valid format supports.

Rationale for choice of transaction format

Click to show/hide

The oldest format that can express a transaction is the format that the largest number of receiving wallets can parse. A wallet that has not yet added support for parsing v7 transactions can still detect funds sent to it in a transaction that does not use v7 features.

Support for receiving funds in v7 transactions

Zcash wallets MUST support parsing v7 transactions by the time they are allowed on the network.

Because the v7 transaction format uses a type-length-value encoding for bundles, a wallet is not required to understand the internal encoding of every bundle in order to parse a transaction. However, a wallet that encounters a bundle with an unrecognized bundleType SHOULD alert the user that the transaction contains components it does not understand. A wallet that encounters a bundle with a recognized bundleType but unrecognized bundleVariant SHOULD alert the user that the transaction affects a pool the wallet is aware of, but in a way the wallet does not fully understand.

For each unsupported (bundleType, bundleVariant) pair in mEffectBundles, a wallet needs the corresponding 32-byte bundle_effects_digest value in order to compute the transaction identifier. This includes an unsupported variant of a recognized bundle type. For each such bundle, the wallet uses the supplied digest as T.3c, together with the bundleType and bundleVariant encoded in that transaction's mEffectBundles entry, in T.3: effects_bundles_digest. It computes the digests of supported bundles normally and includes all bundles in transaction order. The header and complete value pool delta map are hashed as specified in T.1 and T.2. Thus access to the unsupported bundles' digests enables the wallet to compute the transaction identifier without interpreting those bundles' internal payloads. How those digests are made available to the wallet is outside the scope of this ZIP.

The supplied digests act as commitments to subtrees that the wallet does not need to compute. If the resulting transaction identifier matches one obtained from a trusted source, this authenticates the effecting data the wallet understands, the header, and the value pool delta map. Without a transaction identifier obtained from a trusted source, computing the correct identifier instead depends on the supplied bundle digests being correct.

Recognizing a bundle type identifies the affected value pool or protocol component, but does not imply that the wallet understands or can operate under the semantics of an unsupported variant.

A wallet MUST NOT construct or sign a transaction containing a bundle type or variant that it does not fully understand.

Bundle Definitions

The sections above are independent of any particular bundle type. This section defines the bundle types that this ZIP registers: the encoding of their effecting and authorizing data, the sighash algorithm variants available to their signers, and their contributions to the digests defined in Digest Algorithms. A ZIP that registers a further bundle type defines the same things for it, as required by Bundle Type Registration. In particular, each bundle type and variant defines when its entries are present or omitted; the canonical omission rules below apply to the bundle kinds that specify them.

For the bundle types defined by this ZIP, the corresponding authorizing sequences take their lengths from the effecting data:

  • tx_in_auth has tx_in_count elements;
  • vSpendProofsSapling and vSpendAuthSigsSapling each have nSpendsSapling elements;
  • vOutputProofsSapling has nOutputsSapling elements;
  • in each Orchard protocol bundle, vSpendAuthSigsOrchard has nActionsOrchard elements.

Decoding a recognized vBundleData payload MUST consume exactly nBundleDataLen bytes; missing fields, truncated fields, or trailing bytes MUST cause rejection. Unsupported payloads are treated as opaque byte arrays of their declared lengths.

Transparent Bundle

The transparent bundle's value pool delta in mValuePoolDeltas represents the net value flowing from the transparent inputs to the transparent outputs.

An entry for this bundle in mEffectBundles MUST contain at least one transparent input or output. If both tx_in_count and tx_out_count would be zero, the effecting bundle MUST be omitted instead. An entry in mAuthBundles MUST NOT be present when tx_in_count = 0; the empty authorizing bundle is omitted.

A full validator MUST verify that the value pool delta for bundleType = 0 equals the total value of the transparent inputs minus the total value of the transparent outputs. (The input values are not encoded in the transaction itself; they are obtained from the UTXOs being spent.)

This rule applies to coinbase transactions unchanged. A coinbase transaction has no transparent inputs, so its transparent value pool delta is the negation of the total value of its transparent outputs; the value that those outputs consume is contributed to the transparent transaction value pool by the coinbase bundle and the fee bundle.

Transparent Effecting Data

The effecting data for the transparent bundle describes the transparent inputs being spent and the transparent outputs being created.

Bytes Name Data Type Description
varies tx_in_count compactSize Number of transparent inputs.
varies tx_in_effecting TransparentInputEffecting[tx_in_count] Effecting data for each transparent input.
varies tx_out_count compactSize Number of transparent outputs.
varies tx_out TransparentOutput[tx_out_count] Transparent outputs.
4 lock_time uint32 Unix-epoch UTC time or block height, encoded as in Bitcoin.
  • The field lock_time is present if and only if tx_in_count>0\mathtt{tx\_in\_count} > 0. Its effect on consensus is specified in Transaction lock time.
TransparentInputEffecting
Bytes Name Data Type Description
32 prevout_hash byte[32] The transaction ID of the output being spent.
4 prevout_index uint32 The index of the output being spent within that transaction.
4 nSequence uint32 Sequence number, encoded as in Bitcoin.
TransparentOutput
Bytes Name Data Type Description
8 value int64 The value of the output in zatoshi.
varies scriptPubKeyLen compactSize Length of the scriptPubKey.
scriptPubKeyLen scriptPubKey byte[scriptPubKeyLen] The script that must be satisfied to spend this output.
Rationale for the transparent lock time
Click to show/hide

Previous transaction formats encoded lock_time among the fields common to every transaction. The lock time has no effect on a transaction that has no transparent inputs: such a transaction is final whatever its lock time is, and OP_CHECKLOCKTIMEVERIFY is evaluated only in validating a transparent input. In a transaction with no transparent inputs, the field was therefore meaningless, but it was still committed to by the transaction identifier and signatures, and it still had to be chosen.

Encoding the lock time in the transparent bundle keeps it alongside the nSequence fields, which determine whether it applies. Making the field absent when there are no transparent inputs gives such a transaction no lock time to choose, so wallets cannot be distinguished by the value they choose for it. This follows the same pattern as anchorSapling, which is present only when there are Sapling spends.

Transparent Authorizing Data

The authorizing data for the transparent bundle contains the scripts that authorize spending of the referenced transparent inputs.

Bytes Name Data Type Description
varies tx_in_auth TransparentInputAuth[tx_in_count] Authorizing data for each transparent input. The number of entries MUST equal tx_in_count from the effecting data.
TransparentInputAuth
Bytes Name Data Type Description
varies sighashInfo TransparentSighashInfo The sighash variant and associated information for this input, as defined in Transparent Sighash Information (TransparentSighashInfo).
varies scriptSigLen compactSize Length of the scriptSig.
scriptSigLen scriptSig byte[scriptSigLen] The script satisfying the conditions of the referenced output's scriptPubKey.
Transparent Sighash Information (TransparentSighashInfo)
Bytes Name Data Type Description
varies sizeSighashInfo compactSize The size in bytes of sighashInfo.
sizeSighashInfo sighashInfo byte[sizeSighashInfo] The sighash variant and associated information, as defined in Sighash Variants.
Transparent Sighash Algorithms

For the transparent bundle at bundleVariant = 0, sighash variant 0 is the only variant defined, and its associatedData is the empty byte string. A signature made with it commits to the digest defined in Variant 0 Signature Digest, with bundleType = 0, bundleVariant = 0, and the signature_context defined in S.7: Transparent Signature Context.

Transparent Digests
T.3.0: transparent_effects_digest

In the case that transparent inputs or outputs are present, the transparent effects digest is a BLAKE2b-256 hash of the following values:

T.3.0a: prevouts_digest  (32-byte hash)
T.3.0b: sequence_digest  (32-byte hash)
T.3.0c: outputs_digest   (32-byte hash)
T.3.0d: lock_time        (4-byte little-endian, present iff tx_in_count > 0)

The personalization field of this hash is set to:

"ZTxIdTranspaH_v7"

If there are no transparent inputs or outputs, there is no transparent effecting bundle and no entry for it in effects_bundles_digest.

T.3.0a: prevouts_digest

A BLAKE2b-256 hash of the field encoding of all (prevout_hash, prevout_index) pairs from the transparent effecting data.

The personalization field of this hash is set to:

"ZTxIdPrevoutHash"

In the case that the transaction has transparent outputs but no transparent inputs, prevouts_digest is:

BLAKE2b-256("ZTxIdPrevoutHash", [])
T.3.0b: sequence_digest

A BLAKE2b-256 hash of the 32-bit little-endian representation of all nSequence field values from the transparent effecting data.

The personalization field of this hash is set to:

"ZTxIdSequencHash"

In the case that the transaction has transparent outputs but no transparent inputs, sequence_digest is:

BLAKE2b-256("ZTxIdSequencHash", [])
T.3.0c: outputs_digest

A BLAKE2b-256 hash of the concatenated field encodings of all transparent outputs. The field encoding of each output consists of the encoded output value (8-byte little endian) followed by the scriptPubKey byte array (with leading compactSize length).

The personalization field of this hash is set to:

"ZTxIdOutputsHash"

In the case that the transaction has transparent inputs but no transparent outputs, outputs_digest is:

BLAKE2b-256("ZTxIdOutputsHash", [])
S.3: amounts_sig_digest

A BLAKE2b-256 hash of the concatenation, in tx_in_effecting order, of the 8-byte signed little-endian representations of all value fields for the coins spent by the transparent inputs to the transaction.

The personalization field of this hash is set to:

"ZTxTrAmountsHash"

If there are no transparent inputs, including when the transparent bundle is absent, amounts_sig_digest is:

BLAKE2b-256("ZTxTrAmountsHash", [])
S.4: scriptpubkeys_sig_digest

A BLAKE2b-256 hash of the concatenation, in tx_in_effecting order, of the field encodings (each including a leading compactSize) of all scriptPubKey fields for the coins spent by the transparent inputs.

The personalization field of this hash is set to:

"ZTxTrScriptsHash"

If there are no transparent inputs, including when the transparent bundle is absent, scriptpubkeys_sig_digest is:

BLAKE2b-256("ZTxTrScriptsHash", [])
S.7: Transparent Signature Context

For variant 0 of the transparent bundle, signature_context is the concatenation of the following fields for the input being signed:

S.7.i:   prevout      (36 bytes: 32-byte hash + 4-byte index)
S.7.ii:  value        (8-byte signed little-endian)
S.7.iii: scriptPubKey (with compactSize length prefix)
S.7.iv:  nSequence    (4-byte unsigned little-endian)
S.7.v:   input_index  (2-byte unsigned little-endian)

input_index is the zero-based position of the input being signed in tx_in_effecting, in the range 0≤input_index<tx_in_count0 \leq \mathtt{input\_index} < \mathtt{tx\_in\_count}. It is not the prevout_index of the output being spent.

A.1.0: transparent_auth_digest

In the case that the transaction contains transparent inputs, this is a BLAKE2b-256 hash of the following concatenated values for each transparent input:

A.1.0a: TransparentSighashInfo (field encoding bytes)
A.1.0b: scriptSig              (field encoding bytes, with compactSize length prefix)

The field encoding of TransparentSighashInfo is defined in Transparent Sighash Information (TransparentSighashInfo).

The personalization field of this hash is set to:

"ZTxAuthTransHash"

If there are no transparent inputs, there is no transparent authorizing bundle and no entry for it in auth_bundles_digest.

Citation graph

Hover or tap a node to see its title and citations.
Loading citation graph…