ZIP: 230
Title: Version 6 Transaction Format
Owners: Daira-Emma Hopwood <daira-emma@electriccoin.co>
        Jack Grigg <jack@electriccoin.co>
        Sean Bowe <sean@electriccoin.co>
        Kris Nuttycombe <kris@electriccoin.co>
        Pablo Kogan <pablo@qed-it.com>
        Vivek Arte <vivek@qed-it.com>
Original-Authors: Greg Pfeil
                  Deirdre Connolly
Credits: Ying Tong Lai
Status: Draft
Category: Consensus
Created: 2023-04-18
License: MIT
Discussions-To: <https://github.com/zcash/zips/issues/686>

Terminology

The key words "MUST", "SHOULD", and "MAY" in this document are to be interpreted as described in BCP 14 1 when, and only when, they appear in all capitals.

The terms "Zcash Shielded Asset", "OrchardZSA", "ZSA" and "Asset" in this document are to be interpreted as described in ZIP 226 8.

The term "Issuance" and "Issuance Action" in this document are to be interpreted as described in ZIP 227 9.

We define the following additional terms:

The character § is used when referring to sections of the Zcash Protocol Specification 2.

Abstract

This proposal defines a new Zcash peer-to-peer transaction format, which includes data that supports the OrchardZSA protocol and all operations related to Zcash Shielded Assets (ZSAs). The new format adds and describes new fields containing ZSA-specific elements. Like the existing v5 transaction format, it keeps well-bounded regions of the serialized form to serve each pool of funds.

This ZIP also depends upon and defines modifications to the computation of the values TxId Digest, Signature Digest, and Authorizing Data Commitment defined by ZIP 244 11.

This ZIP additionally defines the fee mechanism associated with the Orchard Zcash Shielded Assets (OrchardZSA) protocol as described in ZIP 226 8 and ZIP 227 9. The fee mechanism is defined in terms of modifications to the Proportionak Transfer Fee Mechanism 13.

Motivation

The OrchardZSA protocol requires serialized data elements that are distinct from any previous Zcash transaction. Since ZIP 244 was activated in NU5, the v5 and later serialized transaction formats are not consensus-critical. Thus, this ZIP defines format that can easily accommodate future extensions, where elements or a given pool are kept separate.

The upgrade to the OrchardZSA protocol will also need to define a fee structure consistent with the objectives of ZIP 317 13. This involves adaptation for the transfer protocol 8, as well as additional considerations for the issuance protocol 9 such as fees for asset issuance. Specifically, the OrchardZSA Transfer and Burn mechanism should follow the same fee mechanism in order to not discriminate between transfer bundle types. When it comes to Issuance of ZSA, however, there should be a disincentive that will stop users from flooding the chain with useless asset identifiers. In the case of Issuance, the computational power needed to verify the bundle is not large. The transaction size, however, can be an issue as the number of output notes can be large. Furthermore, as defined in ZIP 227 9, there is an additional data structure in the global state that needs to be maintained as part of the consensus. This motivates further the addition of an Issuance-specific fee.

Requirements

The new format must fully support the OrchardZSA protocol.

The new format should lend itself to future extension or pruning to add or remove value pools.

The computation of the non-malleable transaction identifier hash must include all newly incorporated elements except those that attest to transaction validity.

The computation of the commitment to authorizing data for a transaction must include all newly incorporated elements that attest to transaction validity.

In addition to the requirements of ZIP 317 13, the fee mechanism for the OrchardZSA protocol should satisfy the following requirements:

Non-requirements

More general forms of extensibility, such as definining a key/value format that allows for parsers that are unaware of some components, are not required.

Specification

All fields in this specification are encoded as little-endian.

The Zcash transaction format for transaction version 6 is as follows:

Transaction Format

Bytes Name Data Type Description
Common Transaction Fields
4 header uint32
Contains:
  • fOverwintered flag (bit 31, always set)
  • version (bits 30 .. 0) – transaction version.
4 nVersionGroupId uint32 Version group ID (nonzero).
4 nConsensusBranchId uint32 Consensus branch ID (nonzero).
4 lock_time uint32 Unix-epoch UTC time or block height, encoded as in Bitcoin.
4 nExpiryHeight uint32 A block height in the range {1 .. 499999999} after which the transaction will expire, or 0 to disable expiry. [ZIP-203]
8 fee int64 The fee to be paid by this transaction, in zatoshis.
Transparent Transaction Fields
varies tx_in_count compactSize Number of transparent inputs in tx_in.
varies tx_in tx_in Transparent inputs, encoded as in Bitcoin.
varies tx_out_count compactSize Number of transparent outputs in tx_out.
varies tx_out tx_out Transparent outputs, encoded as in Bitcoin.
Sapling Transaction Fields
varies nSpendsSapling compactSize Number of Sapling Spend descriptions in vSpendsSapling.
96 * nSpendsSapling vSpendsSapling SpendDescriptionV6[nSpendsSapling] A sequence of Sapling Spend descriptions, encoded per protocol §7.3 ‘Spend Description Encoding and Consensus’.
varies nOutputsSapling compactSize Number of Sapling Output Decriptions in vOutputsSapling.
756 * nOutputsSapling vOutputsSapling OutputDescriptionV6[nOutputsSapling] A sequence of Sapling Output descriptions, encoded per protocol §7.4 ‘Output Description Encoding and Consensus’.
8 valueBalanceSapling int64 The net value of Sapling Spends minus Outputs
32 anchorSapling byte[32] A root of the Sapling note commitment tree at some block height in the past.
192 * nSpendsSapling vSpendProofsSapling byte[192 * nSpendsSapling] Encodings of the zk-SNARK proofs for each Sapling Spend.
64 * nSpendsSapling vSpendAuthSigsSapling byte[64 * nSpendsSapling] Authorizing signatures for each Sapling Spend.
192 * nOutputsSapling vOutputProofsSapling byte[192 * nOutputsSapling] Encodings of the zk-SNARK proofs for each Sapling Output.
64 bindingSigSapling byte[64] A Sapling binding signature on the SIGHASH transaction hash.
OrchardZSA Transaction Fields
varies nActionGroupsOrchard compactSize The number of Action Group descriptions in vActionGroupsOrchard. This MUST have a value of either 0 or 1.
varies vActionGroupsOrchard ActionGroupDescription[nActionGroupsOrchard] A sequence of Action Group descriptions, encoded as per the OrchardZSA Action Group Description.
8 valueBalanceOrchard int64 The net value of Orchard spends minus outputs.
varies nAssetBurn compactSize The number of Assets burnt.
40 * nAssetBurn vAssetBurn AssetBurn[nAssetBurn] A sequence of Asset Burn descriptions, encoded per OrchardZSA Asset Burn Description.
64 bindingSigOrchard byte[64] An OrchardZSA binding signature on the SIGHASH transaction hash.
OrchardZSA Issuance Fields
varies nIssueActions compactSize The number of issuance actions in the bundle.
IssueActionSize * nIssueActions vIssueActions IssueAction[nIssueActions] A sequence of issuance action descriptions, where IssueActionSize is the size, in bytes, of an IssueAction description.
32 ik byte[32] The issuance validating key of the issuer, used to validate the signature.
64 issueAuthSig byte[64] The signature of the transaction SIGHASH, signed by the issuer, validated as in Issuance Authorization Signature Scheme 9.
  • The fields valueBalanceSapling and bindingSigSapling are present if and only if \(\mathtt{nSpendsSapling} + \mathtt{nOutputsSapling} > 0\!\) . If valueBalanceSapling is not present, then \(\mathsf{v^{balanceSapling}}\) is defined to be \(0\!\) .
  • The field anchorSapling is present if and only if \(\mathtt{nSpendsSapling} > 0\!\) .
  • The elements of vSpendProofsSapling and vSpendAuthSigsSapling have a 1:1 correspondence to the elements of vSpendsSapling and MUST be ordered such that the proof or signature at a given index corresponds to the SpendDescriptionV6 at the same index.
  • The elements of vOutputProofsSapling have a 1:1 correspondence to the elements of vOutputsSapling and MUST be ordered such that the proof at a given index corresponds to the OutputDescriptionV6 at the same index.
  • The fields valueBalanceOrchard and bindingSigOrchard are present if and only if \(\mathtt{nActionGroupsOrchard} > 0\!\) . If valueBalanceOrchard is not present, then \(\mathsf{v^{balanceOrchard}}\) is defined to be \(0\!\) .
  • The fields ik and issueAuthSig are present if and only if \(\mathtt{nIssueActions} > 0\!\) .
  • For coinbase transactions, the enableSpendsOrchard and enableZSAs bits MUST be set to \(0\!\) .

The encodings of tx_in, and tx_out are as in a version 4 transaction (i.e. unchanged from Canopy). The encodings of SpendDescriptionV6, OutputDescriptionV6 , ActionGroupDescription, AssetBurn and IssueAction are described below. The encoding of Sapling Spends and Outputs has changed relative to prior versions in order to better separate data that describe the effects of the transaction from the proofs of and commitments to those effects, and for symmetry with this separation in the Orchard-related parts of the transaction format.

Sapling Spend Description (SpendDescriptionV6)

Bytes Name Data Type Description
32 cv byte[32] A value commitment to the net value of the input note.
32 nullifier byte[32] The nullifier of the input note.
32 rk byte[32] The randomized validating key for the element of spendAuthSigsSapling corresponding to this Spend.

The encodings of each of these elements are defined in §7.3 ‘Spend Description Encoding and Consensus’ of the Zcash Protocol Specification 3.

Sapling Output Description (OutputDescriptionV6)

Bytes Name Data Type Description
32 cv byte[32] A value commitment to the net value of the output note.
32 cmu byte[32] The \(u\!\) -coordinate of the note commitment for the output note.
32 ephemeralKey byte[32] An encoding of an ephemeral Jubjub public key.
580 encCiphertext byte[580] The encrypted contents of the note plaintext.
80 outCiphertext byte[80] The encrypted contents of the byte string created by concatenation of the transmission key with the ephemeral secret key.

The encodings of each of these elements are defined in §7.4 ‘Output Description Encoding and Consensus’ of the Zcash Protocol Specification 4.

OrchardZSA Action Group Description

The OrchardZSA Action Group Description is encoded in a transaction as an instance of an ActionGroupDescription type:

Bytes Name Data Type Description
varies nActionsOrchard compactSize The number of Action descriptions in vActionsOrchard. This MUST have a value strictly greater than 0.
852 * nActionsOrchard vActionsOrchard OrchardZSAAction[nActionsOrchard] A sequence of OrchardZSA Action descriptions in the Action Group.
1 flagsOrchard byte As defined in Section 7.1 of the Protocol Specification 6.
32 anchorOrchard byte[32] As defined in Section 7.1 of the Protocol Specification 6.
varies sizeProofsOrchard compactSize As defined in Section 7.1 of the Protocol Specification 6.
sizeProofsOrchard proofsOrchard byte[sizeProofsOrchard] The aggregated zk-SNARK proof for all Actions in the Action Group.
4 nAGExpiryHeight uint32 A block height (in the future) after which the Actions of the Action Group become invalid and should be rejected by consensus. This MUST have a value of 0.
64 * nActionsOrchard vSpendAuthSigsOrchard byte[64 * nActionsOrchard] Authorizing signatures for each Action of the Action Group in a transaction.

The encoding of OrchardZSAAction is described below.

  • The proofs aggregated in proofsOrchardZSA, and the elements of vSpendAuthSigsOrchard, each have a 1:1 correspondence to the elements of vActionsOrchard and MUST be ordered such that the proof or signature at a given index corresponds to the OrchardZSAAction at the same index.

Rationale for nAGExpiryHeight

We introduce the nAGExpiryHeight field in this transaction format in order to be forward compatible with Swaps over ZSAs, as proposed in ZIP 228 10. For the OrchardZSA protocol, which does not make use of an additional expiry height for transactions, we set the value of nAGExpiryHeight to be 0 by consensus. This serves as a default value to represent the situation where there is no expiry, analogous to the convention adopted for nExpiryHeight in ZIP 203 [#zip-0203].

OrchardZSA Action Description (OrchardZSAAction)

Bytes Name Data Type Description
32 cv byte[32] A value commitment to the net value of the input note minus the output note.
32 nullifier byte[32] The nullifier of the input note.
32 rk byte[32] The randomized validating key for the element of spendAuthSigsOrchard corresponding to this Action.
32 cmx byte[32] The \(x\!\) -coordinate of the note commitment for the output note.
32 ephemeralKey byte[32] An encoding of an ephemeral Pallas public key.
612 encCiphertext byte[580] The encrypted contents of the note plaintext.
80 outCiphertext byte[80] The encrypted contents of the byte string created by concatenation of the transmission key with the ephemeral secret key.

The encodings of each of these elements are defined in §7.5 ‘Action Description Encoding and Consensus’ of the Zcash Protocol Specification 5.

OrchardZSA Asset Burn Description

An OrchardZSA Asset Burn description is encoded in a transaction as an instance of an AssetBurn type:

Bytes Name Data Type Description
32 AssetBase byte[32] For the OrchardZSA protocol, this is the encoding of the Asset Base \(\mathsf{AssetBase^{Orchard}}\!\) .
8 valueBurn uint64 The amount being burnt. The value is checked by consensus to be non-zero.

The encodings of each of these elements are defined in ZIP 226 8.

Issuance Action Description (IssueAction)

An issuance action, IssueAction, is the instance of issuing a specific Custom Asset, and contains the following fields:

Bytes Name Data Type Description
varies assetDescSize compactSize The length of the asset description string in bytes.
assetDescSize asset_desc byte[assetDescSize] A byte sequence of length assetDescSize bytes which SHOULD be a well-formed UTF-8 code unit sequence according to Unicode 15.0.0 or later.
varies nNotes compactSize The number of notes in the Issuance Action.
147 * nNotes vNotes IssueNote[nNotes] A sequence of note descriptions within the Issuance Action.
1 flagsIssuance byte
An 8-bit value representing a set of flags. Ordered from LSB to MSB:
  • \(\mathsf{finalize}\)
  • The remaining bits are set to \(0\!\) .

The encoding of IssueNote is described below. Note that we allow the number of notes (represented by nNotes) to be zero. This allows for issuers to create Issuance Actions to only finalize an issued Asset, without needing them to simultaneously issue more of that Asset.

Issue Note Description (IssueNote)

An issuance note, IssueNote contains the following fields:

Bytes Name Data Type Description
43 recipient byte[43] The encoding of a recipient's diversified payment address, as \(\mathsf{LEBS2OSP}_{88}(\mathsf{d})\| \mathsf{LEBS2OSP}_{256}(\mathsf{repr}_{\mathbb{P}} (\mathsf{pk}_\mathsf{d}))\!\) , where \(\mathsf{d}\) is the diversifier and \(\mathsf{pk_d}\) is the diversified transmission key. Non Normative Note: This is the same as the encoding of an Orchard Raw Payment Address, as defined in the protocol specification §5.6.4.2 ‘Orchard Raw Payment Addresses’.
8 value uint64 The amount being issued in this note.
32 assetBase byte[32] The encoding of the Asset Base \(\mathsf{AssetBase^{Orchard}}\!\) , as defined in 'ZIP 227'.
32 rho byte[32] This is defined and encoded in the same manner as for Orchard notes in protocol §3.2.1 'Note Plaintexts and Memo Fields'.
32 rseed byte[32] The rseed field of the note, encoded as for Orchard notes in protocol §3.2.1 'Note Plaintexts and Memo Fields'.

Deployment

Version 6 transactions are proposed to be allowed on the network starting from Network Upgrade 7. 12

Reference implementation

TODO

References

1 Information on BCP 14 — "RFC 2119: Key words for use in RFCs to Indicate Requirement Levels" and "RFC 8174: Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words"
2 Zcash Protocol Specification, Version 2024.5.1 or later [NU6]
3 Zcash Protocol Specification, Version 2024.5.1 [NU6]. Section 4.4: Spend Descriptions
4 Zcash Protocol Specification, Version 2024.5.1 [NU6]. Section 4.5: Output Descriptions
5 Zcash Protocol Specification, Version 2024.5.1 [NU6]. Section 4.6: Action Descriptions
6 Zcash Protocol Specification, Version 2022.3.8. Section 7.1: Transaction Encoding and Consensus
7 ZIP 203: Transaction Expiry
8 ZIP 226: Transfer and Burn of Zcash Shielded Assets
9 ZIP 227: Issuance of Zcash Shielded Assets
10 ZIP 228: Asset Swaps for Zcash Shielded Assets
11 ZIP 244: Transaction Identifier Non-Malleability
12 ZIP 254: Deployment of the NU7 Network Upgrade
13 ZIP 317: Proportional Transfer Fee Mechanism
14 ZIP 317: Proportional Transfer Fee Mechanism, Fee calculation