From 472ebe7784f46601b433b49b1e3ce7f3175770a0 Mon Sep 17 00:00:00 2001 From: Vivek Arte <46618816+vivek-arte@users.noreply.github.com> Date: Tue, 16 Apr 2024 14:12:05 +0530 Subject: [PATCH 01/17] Adding the `orchard_zsa_burn_digest` to the TxId digest. (#53) This adds a field to the TxId digest to include the burn fields of the transaction to the SIGHASH. --- zip-0226.html | 26 +++++++++++++++++++++++--- zip-0226.rst | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/zip-0226.html b/zip-0226.html index 4ebbc36b4..2eaebee0a 100644 --- a/zip-0226.html +++ b/zip-0226.html @@ -467,9 +467,10 @@
T.4a: orchard_actions_compact_digest (32-byte hash output) [UPDATED FOR ZSA] T.4b: orchard_actions_memos_digest (32-byte hash output) [UPDATED FOR ZSA] T.4c: orchard_actions_noncompact_digest (32-byte hash output) [UPDATED FOR ZSA] -T.4d: flagsOrchard (1 byte) -T.4e: valueBalanceOrchard (64-bit signed little-endian) -T.4f: anchorOrchard (32 bytes)+T.4d: orchard_zsa_burn_digest (32-byte hash output) [ADDED FOR ZSA] +T.4e: flagsOrchard (1 byte) +T.4f: valueBalanceOrchard (64-bit signed little-endian) +T.4g: anchorOrchard (32 bytes)
A BLAKE2b-256 hash of the subset of Orchard Action information intended to be included in an updated version of the ZIP-307 12 CompactBlock
format for all Orchard Actions belonging to the transaction. For each Action, the following elements are included in the hash:
T.4a.i : nullifier (field encoding bytes) @@ -494,6 +495,25 @@The
The personalization field of this hash is defined identically to ZIP 244:
"ZTxIdOrcActNHash"
A BLAKE2b-256 hash of the data from the burn fields of the transaction. For each tuple in the + \(\mathsf{assetBurn}\) + set, the following elements are included in the hash:
+T.4d.i : assetBase (field encoding bytes) +T.4d.ii: valueBurn (field encoding bytes)+
The personalization field of this hash is set to:
+"ZTxIdOrcBurnHash"+
In case the transaction does not perform the burning of any Assets (i.e. the + \(\mathsf{assetBurn}\) + set is empty), the ''orchard_zsa_burn_digest'' is:
+BLAKE2b-256("ZTxIdOrcBurnHash", [])+
The Asset Base being burnt encoded as the 32-byte representation of a point on the Pallas curve.
+Value of the Asset Base being burnt encoded as little-endian 8-byte representation of 64-bit unsigned integer (e.g. u64 in Rust) raw value.
+The details of the computation of this value are in ZIP 227 7.
diff --git a/zip-0226.rst b/zip-0226.rst index 4d0e1c2f3..826cf6342 100644 --- a/zip-0226.rst +++ b/zip-0226.rst @@ -344,9 +344,10 @@ When Orchard Actions are present in the transaction, this digest is a BLAKE2b-25 T.4a: orchard_actions_compact_digest (32-byte hash output) [UPDATED FOR ZSA] T.4b: orchard_actions_memos_digest (32-byte hash output) [UPDATED FOR ZSA] T.4c: orchard_actions_noncompact_digest (32-byte hash output) [UPDATED FOR ZSA] - T.4d: flagsOrchard (1 byte) - T.4e: valueBalanceOrchard (64-bit signed little-endian) - T.4f: anchorOrchard (32 bytes) + T.4d: orchard_zsa_burn_digest (32-byte hash output) [ADDED FOR ZSA] + T.4e: flagsOrchard (1 byte) + T.4f: valueBalanceOrchard (64-bit signed little-endian) + T.4g: anchorOrchard (32 bytes) T.4a: orchard_actions_compact_digest '''''''''''''''''''''''''''''''''''' @@ -397,6 +398,36 @@ The personalization field of this hash is defined identically to ZIP 244:: "ZTxIdOrcActNHash" + +T.4d: orchard_zsa_burn_digest +''''''''''''''''''''''''''''' + +A BLAKE2b-256 hash of the data from the burn fields of the transaction. For each tuple in +the :math:`\mathsf{assetBurn}` set, the following elements are included in the hash:: + + T.4d.i : assetBase (field encoding bytes) + T.4d.ii: valueBurn (field encoding bytes) + +The personalization field of this hash is set to:: + + "ZTxIdOrcBurnHash" + +In case the transaction does not perform the burning of any Assets (i.e. the +:math:`\mathsf{assetBurn}` set is empty), the ''orchard_zsa_burn_digest'' is:: + + BLAKE2b-256("ZTxIdOrcBurnHash", []) + +T.4d.i: assetBase +................. +The Asset Base being burnt encoded as the 32-byte representation of a point on the +Pallas curve. + +T.4d.ii: valueBurn +.................. +Value of the Asset Base being burnt encoded as little-endian 8-byte representation +of 64-bit unsigned integer (e.g. u64 in Rust) raw value. + + T.5: issuance_digest ```````````````````` The details of the computation of this value are in ZIP 227 [#zip-0227-txiddigest]_. From be397c7c88d7bdaa2ca0a5a71161a557d10f2b0b Mon Sep 17 00:00:00 2001 From: Vivek Arte <46618816+vivek-arte@users.noreply.github.com> Date: Fri, 17 May 2024 10:31:52 +0530 Subject: [PATCH 02/17] Setting transaction to contain issuance fields if and only if a non-zero number of issuance actions are present. (#54) As described in the title, this adds to the transaction format to require that the `ik` and `issueAuthSig` fields be present in the transaction format if and only if there are a non-zero number of issuance actions. --- zip-0227.html | 4 +++- zip-0227.rst | 6 +++++- zip-0230.html | 9 ++++++--- zip-0230.rst | 14 +++++++++----- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/zip-0227.html b/zip-0227.html index 86a06c336..bcd47cb5a 100644 --- a/zip-0227.html +++ b/zip-0227.html @@ -658,7 +658,7 @@ T.5b: issuanceValidatingKey (32 bytes)The personalization field of this hash is set to:
"ZTxIdSAIssueHash"-
In case the transaction has no issuance components, ''issue_actions_digest'' is:
+In case the transaction has no issuance components, ''issuance_digest'' is:
BLAKE2b-256("ZTxIdSAIssueHash", [])
A BLAKE2b-256 hash of Issue Action information for all Issuance Actions belonging to the transaction. For each Action, the following elements are included in the hash:
@@ -676,6 +676,8 @@ T.5a.i.5: rseed (field encoding bytes)The personalization field of this hash is set to:
"ZTxIdIAcNoteHash"+
In case the transaction has no Issue Notes, ''issue_notes_digest'' is:
+BLAKE2b-256("ZTxIdIAcNoteHash", [])
This is the raw encoding of an Orchard shielded payment address as defined in the protocol specification 21.
anchorSapling
is present if and only if
\(\mathtt{nSpendsSapling} > 0\!\)
.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.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.flagsOrchard
, valueBalanceOrchard
, anchorOrchard
, sizeProofsOrchardZSA
, proofsOrchardZSA
, and bindingSigOrchard
are present if and only if
\(\mathtt{nActionsOrchard} > 0\!\)
. If valueBalanceOrchard
is not present, then
@@ -331,9 +333,10 @@
is defined to be
\(0\!\)
.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.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.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.ik
and issueAuthSig
are present if and only if
+ \(\mathtt{nIssueActions} > 0\!\)
+ .enableSpendsOrchard
and enableZSAs
bits MUST be set to
\(0\!\)
.The encodings of each of these elements are defined in ZIP 227 7.
+The encodings of each of these elements are defined in ZIP 227 7. 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.
byte[64 * nActionsOrchard]
64
bindingSigOrchard
byte[64]
varies
nAssetBurn
AssetBurn[nAssetBurn]
64
bindingSigOrchard
byte[64]
valueBurn
uint64
2
varies
assetDescSize
byte
compactSize
varies
nNotes
compactSize
noteSize * nNotes
147 * nNotes
vNotes
Note[nNotes]
noteSize
is the size, in bytes, of a Note.IssueNote[nNotes]
1
The encodings of each of these elements are defined in ZIP 227 7. 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.
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.
IssueNote
) An issuance note, IssueNote
contains the following fields:
Bytes | +Name | +Data Type | +Description | +
---|---|---|---|
43 |
+ recipient |
+ byte[43] |
+ The raw encoding of an Orchard Raw Payment Address, as per protocol §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 'Notes'. | +
32 |
+ rseed |
+ byte[32] |
+ The rseed field of the note, encoded as for Orchard notes in protocol §3.2 'Notes'. |
+
For Split Notes, the nullifier is generated as follows:
-where - \(\text{ψ}'\) + \(\text{ψ}^{\mathsf{nf}}\) is sampled uniformly at random on \(\mathbb{F}_{q_{\mathbb{P}}}\!\) , diff --git a/zip-0226.rst b/zip-0226.rst index 826cf6342..d00e83216 100644 --- a/zip-0226.rst +++ b/zip-0226.rst @@ -243,9 +243,9 @@ Wallets and other clients have to choose from the following to ensure the Asset For Split Notes, the nullifier is generated as follows: -.. math:: \mathsf{nf_{old}} = \mathsf{Extract}_{\mathbb{P}} ([(\mathsf{PRF^{nfOrchard}_{nk}} (\text{ρ}^{\mathsf{old}}) + \text{ψ}') \bmod q_{\mathbb{P}}]\,\mathcal{K}^\mathsf{Orchard} + \mathsf{cm^{old}} + \mathcal{L}^\mathsf{Orchard}) +.. math:: \mathsf{nf_{old}} = \mathsf{Extract}_{\mathbb{P}} ([(\mathsf{PRF^{nfOrchard}_{nk}} (\text{ρ}^{\mathsf{old}}) + \text{ψ}^{\mathsf{nf}}) \bmod q_{\mathbb{P}}]\,\mathcal{K}^\mathsf{Orchard} + \mathsf{cm^{old}} + \mathcal{L}^\mathsf{Orchard}) -where :math:`\text{ψ}'` is sampled uniformly at random on :math:`\mathbb{F}_{q_{\mathbb{P}}}\!`, :math:`\mathcal{K}^{\mathsf{Orchard}}` is the Orchard Nullifier Base as defined in [#protocol-commitmentsandnullifiers]_, and :math:`\mathcal{L}^{\mathsf{Orchard}} := \mathsf{GroupHash^{\mathbb{P}}}(\texttt{"z.cash:Orchard"}, \texttt{"L"})\!`. +where :math:`\text{ψ}^{\mathsf{nf}}` is sampled uniformly at random on :math:`\mathbb{F}_{q_{\mathbb{P}}}\!`, :math:`\mathcal{K}^{\mathsf{Orchard}}` is the Orchard Nullifier Base as defined in [#protocol-commitmentsandnullifiers]_, and :math:`\mathcal{L}^{\mathsf{Orchard}} := \mathsf{GroupHash^{\mathbb{P}}}(\texttt{"z.cash:Orchard"}, \texttt{"L"})\!`. Rationale for Split Notes ````````````````````````` From be9d90c89f5e7bd0266aeea3f1bd1458f720a933 Mon Sep 17 00:00:00 2001 From: Vivek Arte <46618816+vivek-arte@users.noreply.github.com> Date: Sun, 11 Aug 2024 20:25:05 +0530 Subject: [PATCH 05/17] Clarification about protocol behaviour when enableZSAs is set to true. (#57) This resolves https://github.com/zcash/zips/issues/846 --- zip-0226.html | 6 +++++- zip-0226.rst | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/zip-0226.html b/zip-0226.html index a1b8fe8ee..df2f822d8 100644 --- a/zip-0226.html +++ b/zip-0226.html @@ -66,7 +66,11 @@ computation defined in ZIP 227 5.
We include the ability to pause the ZSA functionality, via a \(\mathsf{enableZSA}\) - boolean flag. When this flag is set to false, it is not possible to perform transactions involving Custom Assets (the Action statement as modified for ZSAs will not be satisfied).
+ boolean flag. When this flag is set to false, the proof will fail for any non-native Asset, making it impossible to perform transactions involving Custom Assets. When this flag is set to true, the circuit will allow transactions involving Custom Assets subject to the values of the + \(\mathsf{enableSpendsOrchard}\) + and + \(\mathsf{enableOutputsOrchard}\) + flags, similar to the vanilla Orchard setting.Finally, in this ZIP we also describe the burn mechanism, which is a direct extension of the transfer mechanism. The burn process uses a similar mechanism to what is used in Orchard to unshield ZEC, by using the \(\mathsf{valueBalance}\) of the Asset in question. Burning Assets is useful for many purposes, including bridging of Wrapped Assets and removing supply of Assets.
diff --git a/zip-0226.rst b/zip-0226.rst index d00e83216..0e5e833a4 100644 --- a/zip-0226.rst +++ b/zip-0226.rst @@ -60,7 +60,9 @@ Because in a single transaction all value commitments are balanced, there must b In order to ensure the security of the transfers, and as we will explain below, we are redefining input dummy notes [#protocol-orcharddummynotes]_ for Custom Assets, as we need to enforce that the :math:`\mathsf{AssetBase}` of the output note of that Split Action is the output of a valid :math:`\mathsf{ZSAValueBase}` computation defined in ZIP 227 [#zip-0227]_. -We include the ability to pause the ZSA functionality, via a :math:`\mathsf{enableZSA}` boolean flag. When this flag is set to false, it is not possible to perform transactions involving Custom Assets (the Action statement as modified for ZSAs will not be satisfied). +We include the ability to pause the ZSA functionality, via a :math:`\mathsf{enableZSA}` boolean flag. +When this flag is set to false, the proof will fail for any non-native Asset, making it impossible to perform transactions involving Custom Assets. +When this flag is set to true, the circuit will allow transactions involving Custom Assets subject to the values of the :math:`\mathsf{enableSpendsOrchard}` and :math:`\mathsf{enableOutputsOrchard}` flags, similar to the vanilla Orchard setting. Finally, in this ZIP we also describe the *burn* mechanism, which is a direct extension of the transfer mechanism. The burn process uses a similar mechanism to what is used in Orchard to unshield ZEC, by using the :math:`\mathsf{valueBalance}` of the Asset in question. Burning Assets is useful for many purposes, including bridging of Wrapped Assets and removing supply of Assets. From c0c2600b34e36879843935cd1da04a9550be4c1d Mon Sep 17 00:00:00 2001 From: Vivek Arte <46618816+vivek-arte@users.noreply.github.com> Date: Thu, 15 Aug 2024 14:52:23 +0530 Subject: [PATCH 06/17] Updating specification of the global issuance state, the issued_assets map (#59) This adds a map called `issued_assets` to the global state. This is used to track ZSA balances in the shielded pool along the lines of ZIP 209. This should resolve https://github.com/zcash/zips/issues/844. --- rendered/zip-0226.html | 154 +++++++++++++++++++++++----------------- rendered/zip-0227.html | 156 ++++++++++++++++++++++++++--------------- zips/zip-0226.rst | 10 ++- zips/zip-0227.rst | 34 +++++++-- 4 files changed, 221 insertions(+), 133 deletions(-) diff --git a/rendered/zip-0226.html b/rendered/zip-0226.html index c54818e33..5fdacb6ce 100644 --- a/rendered/zip-0226.html +++ b/rendered/zip-0226.html @@ -32,7 +32,7 @@The Asset Identifier (via means of the Asset Digest and Asset Base) will be used to enforce that the balance of an Action Description 15 28 is preserved across Assets (see the Orchard Binding Signature 18), and by extension the balance of an Orchard transaction. That is, the sum of all the +
The Asset Identifier (via means of the Asset Digest and Asset Base) will be used to enforce that the balance of an Action Description 16 29 is preserved across Assets (see the Orchard Binding Signature 19), and by extension the balance of an Orchard transaction. That is, the sum of all the \(\mathsf{value^{net}}\) from each Action Description, computed as \(\mathsf{value^{old}} - \mathsf{value^{new}}\!\) , must be balanced only with respect to the same Asset Identifier. This is especially important since we will allow different Action Descriptions to transfer notes of different Asset Identifiers, where the overall balance is checked without revealing which (or how many distinct) Assets are being transferred.
-As was initially proposed by Jack Grigg and Daira-Emma Hopwood 29 30, we propose to make this happen by changing the value base point, +
As was initially proposed by Jack Grigg and Daira-Emma Hopwood 30 31, we propose to make this happen by changing the value base point, \(\mathcal{V}^{\mathsf{Orchard}}\!\) , in the Homomorphic Pedersen Commitment that derives the value commitment, \(\mathsf{cv^{net}}\!\) , of the net value in an Orchard Action.
-Because in a single transaction all value commitments are balanced, there must be as many different value base points as there are Asset Identifiers for a given shielded protocol used in a transaction. We propose to make the Asset Base an auxiliary input to the proof for each Action statement 20, represented already as a point on the Pallas curve. The circuit then should check that the same Asset Base is used in the old note commitment and the new note commitment 25, and as the base point in the value commitment 24. This ensures (1) that the input and output notes are of the same Asset Base, and (2) that only Actions with the same Asset Base will balance out in the Orchard binding signature.
-In order to ensure the security of the transfers, and as we will explain below, we are redefining input dummy notes 17 for Custom Assets, as we need to enforce that the +
Because in a single transaction all value commitments are balanced, there must be as many different value base points as there are Asset Identifiers for a given shielded protocol used in a transaction. We propose to make the Asset Base an auxiliary input to the proof for each Action statement 21, represented already as a point on the Pallas curve. The circuit then should check that the same Asset Base is used in the old note commitment and the new note commitment 26, and as the base point in the value commitment 25. This ensures (1) that the input and output notes are of the same Asset Base, and (2) that only Actions with the same Asset Base will balance out in the Orchard binding signature.
+In order to ensure the security of the transfers, and as we will explain below, we are redefining input dummy notes 18 for Custom Assets, as we need to enforce that the \(\mathsf{AssetBase}\) of the output note of that Split Action is the output of a valid \(\mathsf{ZSAValueBase}\) @@ -98,7 +98,7 @@ be the type of a ZSA note, i.e. \(\mathsf{Note^{OrchardZSA}} := \mathsf{Note^{Orchard}} \times \mathbb{P}^*\!\) .
-An Orchard ZSA note differs from an Orchard note 14 by additionally including the Asset Base, +
An Orchard ZSA note differs from an Orchard note 15 by additionally including the Asset Base, \(\mathsf{AssetBase}\!\) . So a ZSA note is a tuple \((\mathsf{g_d}, \mathsf{pk_d}, \mathsf{v}, \text{ρ}, \text{ψ}, \mathsf{AssetBase})\!\) @@ -106,7 +106,7 @@
where \(\mathbb{P}, \ell_{\mathbb{P}}, q_{\mathbb{P}}\) - are as defined for the Pallas curve 26, and where + are as defined for the Pallas curve 27, and where \(\mathsf{NoteCommit^{Orchard}}.\!\mathsf{Trapdoor}\) and \(\mathsf{Orchard}.\!\mathsf{Output}\) - are as defined in the Zcash protocol specification 16. This note commitment scheme is instantiated using the Sinsemilla Commitment 25 as follows:
+ are as defined in the Zcash protocol specification 17. This note commitment scheme is instantiated using the Sinsemilla Commitment 26 as follows:The nullifier is generated in the same manner as in the Orchard protocol 19.
-The ZSA note plaintext also includes the Asset Base in addition to the components in the Orchard note plaintext 27. It consists of
+ is as defined in §5.1 22 of the Zcash protocol specification. +The nullifier is generated in the same manner as in the Orchard protocol 20.
+The ZSA note plaintext also includes the Asset Base in addition to the components in the Orchard note plaintext 28. It consists of
In the ZSA protocol, the instance of the note commitment scheme, \(\mathsf{NoteCommit^{OrchardZSA}_{rcm}}\!\) , differs from the Orchard note commitment \(\mathsf{NoteCommit^{Orchard}_{rcm}}\) - in that for Custom Assets, the Asset Base will be added as an input to the commitment computation. In the case where the Asset is the ZEC Asset, the commitment is computed identically to the Orchard note commitment, without making use of the ZEC Asset Base as an input. As we will see, the nested structure of the Sinsemilla-based commitment 25 allows us to add the Asset Base as a final recursive step.
-The note commitment output is still indistinguishable from the original Orchard ZEC note commitments, by definition of the Sinsemilla hash function 23. ZSA note commitments will therefore be added to the same Orchard Note Commitment Tree. In essence, we have:
+ in that for Custom Assets, the Asset Base will be added as an input to the commitment computation. In the case where the Asset is the ZEC Asset, the commitment is computed identically to the Orchard note commitment, without making use of the ZEC Asset Base as an input. As we will see, the nested structure of the Sinsemilla-based commitment 26 allows us to add the Asset Base as a final recursive step. +The note commitment output is still indistinguishable from the original Orchard ZEC note commitments, by definition of the Sinsemilla hash function 24. ZSA note commitments will therefore be added to the same Orchard Note Commitment Tree. In essence, we have:
This definition can be viewed as a generalization of the Orchard note commitment, and will allow maintaining a single commitment instance for the note commitment, which will be used both for pre-ZSA Orchard and ZSA notes.
The Orchard Protocol uses a Homomorphic Pedersen Commitment 24 to perform the value commitment, with fixed base points +
The Orchard Protocol uses a Homomorphic Pedersen Commitment 25 to perform the value commitment, with fixed base points \(\mathcal{V}^{\mathsf{Orchard}}\) and \(\mathcal{R}^{\mathsf{Orchard}}\) @@ -214,25 +214,39 @@ set.
If all these checks pass, then for every + \((\mathsf{AssetBase}, \mathsf{v}) \in \mathsf{assetBurn}\!\) + , reduce the value of + \(\mathsf{issued\_assets(AssetBase).balance}\) + in the global state by + \(\mathsf{v}\!\) + .
Note: Even if this mechanism allows having transparent ↔ shielded Asset transfers in theory, the transparent protocol will not be changed with this ZIP to adapt to a multiple Asset structure. This means that unless future consensus rules changes do allow it, unshielding will not be possible for Custom Assets.
In order to verify the balance of the different Assets, the verifier MUST perform a similar process as for the Orchard protocol 18, with the addition of the burn information.
+In order to verify the balance of the different Assets, the verifier MUST perform a similar process as for the Orchard protocol 19, with the addition of the burn information.
For a total of \(n\) Actions in a transfer, the prover MUST still sign the SIGHASH transaction hash using the binding signature key @@ -255,7 +269,7 @@ the set of indices of Actions that are related to Custom Assets.
The right hand side of the value balance verification equation can be expanded to:
This equation contains the balance check of the Orchard protocol 18. With ZSA, transfer Actions for Custom Assets must also be balanced across Asset Bases. All Custom Assets are contained within the shielded pool, and cannot be unshielded via a regular transfer. Custom Assets can be burnt, the mechanism for which reveals the amount and identifier of the Asset being burnt, within the +
This equation contains the balance check of the Orchard protocol 19. With ZSA, transfer Actions for Custom Assets must also be balanced across Asset Bases. All Custom Assets are contained within the shielded pool, and cannot be unshielded via a regular transfer. Custom Assets can be burnt, the mechanism for which reveals the amount and identifier of the Asset being burnt, within the \(\mathsf{assetBurn}\) set. As such, for a correctly constructed transaction, we will get \(\sum_{j \in S_{\mathsf{CA}}} \mathsf{cv}^{\mathsf{net}}_j - \sum_{(\mathsf{AssetBase}, \mathsf{v}) \in \mathsf{assetBurn}} [\mathsf{v}]\,\mathsf{AssetBase} = \sum_{j \in S_{\mathsf{CA}}} [\mathsf{rcv}^{\mathsf{net}}_j]\,\mathcal{R}^{\mathsf{Orchard}}\!\) @@ -304,11 +318,11 @@ \(\mathbb{F}_{q_{\mathbb{P}}}\!\) , \(\mathcal{K}^{\mathsf{Orchard}}\) - is the Orchard Nullifier Base as defined in 19, and + is the Orchard Nullifier Base as defined in 20, and \(\mathcal{L}^{\mathsf{Orchard}} := \mathsf{GroupHash^{\mathbb{P}}}(\texttt{"z.cash:Orchard"}, \texttt{"L"})\!\) .
In the Orchard protocol, since each Action represents an input and an output, the transaction that wants to send one input to multiple outputs must have multiple inputs. The Orchard protocol gives dummy spend notes 17 to the Actions that have not been assigned input notes.
+In the Orchard protocol, since each Action represents an input and an output, the transaction that wants to send one input to multiple outputs must have multiple inputs. The Orchard protocol gives dummy spend notes 18 to the Actions that have not been assigned input notes.
The Orchard technique requires modification for the ZSA protocol with multiple Asset Identifiers, as the output note of the split Actions cannot contain just any Asset Base. We must enforce it to be an actual output of a GroupHash computation (in fact, we want it to be of the same Asset Base as the original input note, but the binding signature takes care that the proper balancing is performed). Without this enforcement the prover could input a multiple (or linear combination) of an existing Asset Base, and thereby attack the network by overflowing the ZEC value balance and hence counterfeiting ZEC funds.
Therefore, for Custom Assets we enforce that every input note to an ZSA Action must be proven to exist in the set of note commitments in the note commitment tree. We then enforce this real note to be “unspendable” in the sense that its value will be zeroed in split Actions and the nullifier will be randomized, making the note not spendable in the specific Action. Then, the proof itself ensures that the output note is of the same Asset Base as the input note. In the circuit, the split note functionality will be activated by a boolean private input to the proof (aka the \(\mathsf{split\_flag}\) @@ -317,8 +331,8 @@
Every ZSA Action statement is closely similar to the Orchard Action statement 20, except for a few additions that ensure the security of the Asset Identifier system. We detail these changes below.
-All modifications in the Circuit are detailed in 31.
+Every ZSA Action statement is closely similar to the Orchard Action statement 21, except for a few additions that ensure the security of the Asset Identifier system. We detail these changes below.
+All modifications in the Circuit are detailed in 32.
The following constraints must be added to ensure that the input and output note are of the same \(\mathsf{AssetBase}\!\) @@ -327,12 +341,12 @@
The input note in the old note commitment integrity check must either include an Asset Base (ZSA note) or not (pre-ZSA Orchard note). If the note is a pre-ZSA Orchard note, the note commitment is computed in the original Orchard fashion 16. If the note is a ZSA note, the note commitment is computed as defined in the Note Structure & Commitment section.
+The input note in the old note commitment integrity check must either include an Asset Base (ZSA note) or not (pre-ZSA Orchard note). If the note is a pre-ZSA Orchard note, the note commitment is computed in the original Orchard fashion 17. If the note is a ZSA note, the note commitment is computed as defined in the Note Structure & Commitment section.
The transaction format for v6 transactions is described in ZIP 230 10.
+The transaction format for v6 transactions is described in ZIP 230 11.
The transaction digest algorithm defined in ZIP 244 11 is modified by the ZSA protocol to add a new branch for issuance information, along with modifications within the orchard_digest
to account for the inclusion of the Asset Base. The details of these changes are described in this section, and highlighted using the [UPDATED FOR ZSA]
or [ADDED FOR ZSA]
text label. We omit the details of the sections that do not change for the ZSA protocol.
The transaction digest algorithm defined in ZIP 244 12 is modified by the ZSA protocol to add a new branch for issuance information, along with modifications within the orchard_digest
to account for the inclusion of the Asset Base. The details of these changes are described in this section, and highlighted using the [UPDATED FOR ZSA]
or [ADDED FOR ZSA]
text label. We omit the details of the sections that do not change for the ZSA protocol.
A BLAKE2b-256 hash of the following values
T.1: header_digest (32-byte hash output) @@ -465,7 +479,7 @@-The T.3: sapling_digest (32-byte hash output) T.4: orchard_digest (32-byte hash output) [UPDATED FOR ZSA] T.5: issuance_digest (32-byte hash output) [ADDED FOR ZSA]
The personalization field remains the same as in ZIP 244 11.
+The personalization field remains the same as in ZIP 244 12.
When Orchard Actions are present in the transaction, this digest is a BLAKE2b-256 hash of the following values
T.4a: orchard_actions_compact_digest (32-byte hash output) [UPDATED FOR ZSA] @@ -476,7 +490,7 @@The T.4f: valueBalanceOrchard (64-bit signed little-endian) T.4g: anchorOrchard (32 bytes)
A BLAKE2b-256 hash of the subset of Orchard Action information intended to be included in an updated version of the ZIP-307 12 CompactBlock
format for all Orchard Actions belonging to the transaction. For each Action, the following elements are included in the hash:
A BLAKE2b-256 hash of the subset of Orchard Action information intended to be included in an updated version of the ZIP-307 13 CompactBlock
format for all Orchard Actions belonging to the transaction. For each Action, the following elements are included in the hash:
T.4a.i : nullifier (field encoding bytes) T.4a.ii : cmx (field encoding bytes) T.4a.iii: ephemeralKey (field encoding bytes) @@ -491,7 +505,7 @@The
"ZTxIdOrcActMHash"
A BLAKE2b-256 hash of the remaining subset of Orchard Action information not intended for inclusion in an updated version of the the ZIP 307 12 CompactBlock
format, for all Orchard Actions belonging to the transaction. For each Action, the following elements are included in the hash:
A BLAKE2b-256 hash of the remaining subset of Orchard Action information not intended for inclusion in an updated version of the the ZIP 307 13 CompactBlock
format, for all Orchard Actions belonging to the transaction. For each Action, the following elements are included in the hash:
T.4d.i : cv (field encoding bytes) T.4d.ii : rk (field encoding bytes) T.4d.iii: encCiphertext[596..] (post-memo suffix of field encoding) [UPDATED FOR ZSA] @@ -520,12 +534,12 @@The
The details of the computation of this value are in ZIP 227 7.
+The details of the computation of this value are in ZIP 227 8.
The fee mechanism for the upgrades proposed in this ZIP will follow the mechanism described in ZIP 317 for the ZSA protocol upgrade 13.
+The fee mechanism for the upgrades proposed in this ZIP will follow the mechanism described in ZIP 317 for the ZSA protocol upgrade 14.
In order to have backward compatibility with the ZEC notes, we have designed the circuit to support both ZEC and ZSA notes. As we specify above, there are three main reasons we can do this:
@@ -609,10 +623,18 @@6 | +ZIP 227: Issuance of Zcash Shielded Assets: Specification: Global Issuance State | +
---|
7 | ZIP 227: Issuance of Zcash Shielded Assets: Specification: Asset Identifier |
---|
7 | +8 | ZIP 227: Issuance of Zcash Shielded Assets: TxId Digest - Issuance |
---|
8 | +9 | ZIP 227: Issuance of Zcash Shielded Assets: Signature Digest |
---|
9 | +10 | ZIP 227: Issuance of Zcash Shielded Assets: Authorizing Data Commitment |
---|
10 | +11 | ZIP 230: Version 6 Transaction Format |
---|
11 | +12 | ZIP 244: Transaction Identifier Non-Malleability |
---|
12 | +13 | ZIP 307: Light Client Protocol for Payment Detection |
---|
13 | +14 | ZIP 317: Proportional Transfer Fee Mechanism - Pull Request #667 for ZSA Protocol ZIPs |
---|
14 | +15 | Zcash Protocol Specification, Version 2023.4.0. Section 3.2: Notes |
---|
15 | +16 | Zcash Protocol Specification, Version 2023.4.0. Section 3.7: Action Transfers and their Descriptions |
---|
16 | +17 | Zcash Protocol Specification, Version 2023.4.0. Section 4.1.8: Commitment |
---|
17 | +18 | Zcash Protocol Specification, Version 2023.4.0. Section 4.8.3: Dummy Notes (Orchard) |
---|
18 | +19 | Zcash Protocol Specification, Version 2023.4.0. Section 4.14: Balance and Binding Signature (Orchard) |
---|
19 | +20 | Zcash Protocol Specification, Version 2023.4.0. Section 4.16: Note Commitments and Nullifiers |
---|
20 | +21 | Zcash Protocol Specification, Version 2023.4.0. Section 4.17.4: Action Statement (Orchard) |
---|
21 | +22 | Zcash Protocol Specification, Version 2023.4.0. Section 5.1: Integers, Bit Sequences, and Endianness |
---|
22 | +23 | Zcash Protocol Specification, Version 2023.4.0. Section 5.3: Constants |
---|
23 | +24 | Zcash Protocol Specification, Version 2023.4.0. Section 5.4.1.9: Sinsemilla hash function |
---|
24 | +25 | Zcash Protocol Specification, Version 2023.4.0. Section 5.4.8.3: Homomorphic Pedersen commitments (Sapling and Orchard) |
---|
25 | +26 | Zcash Protocol Specification, Version 2023.4.0. Section 5.4.8.4: Sinsemilla commitments |
---|
26 | +27 | Zcash Protocol Specification, Version 2023.4.0. Section 5.4.9.6: Pallas and Vesta |
---|
27 | +28 | Zcash Protocol Specification, Version 2023.4.0. Section 5.5: Encodings of Note Plaintexts and Memo Fields |
---|
28 | +29 | Zcash Protocol Specification, Version 2023.4.0. Section 7.5: Action Description Encoding and Consensus |
---|
29 | +30 | User-Defined Assets and Wrapped Assets |
---|
30 | +31 | Comment on Generalized Value Commitments |
---|
31 | +32 | Modifications to the Orchard circuit for the ZSA Protocol |
---|
8 | +ZIP 209: Prohibit Negative Shielded Chain Value Pool Balances | +
---|
9 | ZIP 224: Orchard |
---|
9 | +10 | ZIP 226: Transfer and Burn of Zcash Shielded Assets |
---|
10 | +11 | ZIP 226: Transfer and Burn of Zcash Shielded Assets - Note Structure & Commitment |
---|
11 | +12 | ZIP 226: Transfer and Burn of Zcash Shielded Assets - TxId Digest |
---|
12 | +13 | ZIP 244: Transaction Identifier Non-Malleability |
---|
13 | +14 | ZIP 244: Transaction Identifier Non-Malleability: Signature Digest |
---|
14 | +15 | ZIP 244: Transaction Identifier Non-Malleability: Authorizing Data Commitment |
---|
15 | +16 | ZIP 317: Proportional Transfer Fee Mechanism |
---|
16 | +17 | BIP 340: Schnorr Signatures for secp256k1 |
---|
17 | +18 | Zcash Protocol Specification, Version 2023.4.0. Section 2: Notation |
---|
18 | +19 | Zcash Protocol Specification, Version 2023.4.0. Section 3.1: Payment Addresses and Keys |
---|
19 | +20 | Zcash Protocol Specification, Version 2023.4.0. Section 4.2.3: Orchard Key Components |
---|
20 | +21 | Zcash Protocol Specification, Version 2023.4.0. Section 5.4.9.8: Group Hash into Pallas and Vesta |
---|
21 | +22 | Zcash Protocol Specification, Version 2023.4.0. Section 5.6.4.2: Orchard Raw Payment Addresses |
---|
22 | +23 | Zcash Protocol Specification, Version 2023.4.0. Section 7.1: Transaction Encoding and Consensus (Transaction Version 5) |
---|---|---|
11 | -ZIP 230: Version 6 Transaction Format | +ZIP 230: Version 6 Transaction Format |
3 | -ZIP 32: Shielded Hierarchical Deterministic Wallets - Orchard master key generation | +ZIP 32: Shielded Hierarchical Deterministic Wallets - Specification: Hardened-only key derivation |
---|
4 | -ZIP 32: Shielded Hierarchical Deterministic Wallets - Orchard child key derivation | +ZIP 32: Shielded Hierarchical Deterministic Wallets - Hardened-only child key derivation |
---|
32
rho
byte[32]
32
rseed
byte[32]
rseed
field of the note, encoded as for Orchard notes in protocol §3.2 'Notes'.rseed
field of the note, encoded as for Orchard notes in protocol §3.2.1 'Note Plaintexts and Memo Fields'.We use hardened-only child key derivation as defined in ZIP 32 4 for the issuance authorizing key.
- \(\mathsf{CDKsk}((\mathsf{sk}_{par},\mathsf{c}_{par}), i) \rightarrow (\mathsf{sk}_{i}, \mathsf{c}_{i})\) + \(\mathsf{CKDsk}((\mathsf{sk}_{par},\mathsf{c}_{par}), i) \rightarrow (\mathsf{sk}_{i}, \mathsf{c}_{i})\)
43
recipient
byte[43]
8
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 character § is used when referring to sections of the Zcash Protocol Specification 2.
+The terms "Zcash Shielded Asset", "ZSA" and "Asset" in this document are to be interpreted as described in ZIP 226 7.
+The term "Issuance" and "Issuance Action" in this document are to be interpreted as described in ZIP 227 8.
+We define the following additional terms:
+The character § is used when referring to sections of the Zcash Protocol Specification 2.
This proposal defines a new Zcash peer-to-peer transaction format, which includes data that supports the Orchard-ZSA 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 8.
+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 9.
+This ZIP additionally defines the fee mechanism associated with the Orchard Zcash Shielded Assets (OrchardZSA) protocol as described in ZIP 226 7 and ZIP 227 8. The fee mechanism is defined in terms of modifications to the Proportionak Transfer Fee Mechanism 10.
The Orchard-ZSA 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 10. This involves adaptation for the transfer protocol 7, as well as additional considerations for the issuance protocol 8 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 8, 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.
The new format must fully support the Orchard-ZSA 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 10, the fee mechanism for the OrchardZSA protocol should satisfy the following 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.
@@ -306,7 +319,7 @@64
issueAuthSig
byte[64]
The encodings of each of these elements are defined in §7.3 ‘Spend Description Encoding and Consensus’ of the Zcash Protocol Specification 3.
+The encodings of each of these elements are defined in §7.3 ‘Spend Description Encoding and Consensus’ of the Zcash Protocol Specification 3.
OutputDescriptionV6
) The encodings of each of these elements are defined in §7.4 ‘Output Description Encoding and Consensus’ of the Zcash Protocol Specification 4.
+The encodings of each of these elements are defined in §7.4 ‘Output Description Encoding and Consensus’ of the Zcash Protocol Specification 4.
OrchardZsaAction
) The encodings of each of these elements are defined in §7.5 ‘Action Description Encoding and Consensus’ of the Zcash Protocol Specification 5.
+The encodings of each of these elements are defined in §7.5 ‘Action Description Encoding and Consensus’ of the Zcash Protocol Specification 5.
An Orchard-ZSA Asset Burn description is encoded in a transaction as an instance of an AssetBurn
type:
The encodings of each of these elements are defined in ZIP 226 6.
+The encodings of each of these elements are defined in ZIP 226 7.
IssueAction
) An issuance action, IssueAction
, is the instance of issuing a specific Custom Asset, and contains the following fields:
In addition to the parameters defined in the Fee calculation section of ZIP 317 11, the OrchardZSA protocol upgrade defines the following additional parameters:
+Parameter | +Value | +
---|---|
+ \(issuance\_fee\) + | ++ \(100 \cdot marginal\_fee\) + per issuance action (as defined below) | +
Wallets implementing this specification SHOULD use a conventional fee, viz. + \(zsa\_conventional\_fee\) + , that is calculated in zatoshis. Additional definitions that are used in the formula for the calculation are in the table below:
+Input | +Units | +Description | +
---|---|---|
+ \(nOrchardActions\) + | +number | +the number of OrchardZSA transfer actions (including ZEC actions) | +
+ \(nTotalOutputsZsaIssuance\) + | +number | +the total number of OrchardZSA issuance outputs (added across issuance actions) | +
+ \(nCreateActions\) + | +number | +the number of OrchardZSA issuance actions that issue a Custom Asset that is not present in the Global Issuance State | +
The other inputs to this formula are taken from transaction fields defined in the Zcash protocol specification 6 and the global state. They are defined in the Fee calculation section of ZIP 317 11. Note that + \(nOrchardActions\) + , that is used in the computation of + \(logical\_actions\) + , is redefined in the above table, and now combines the actions for native ZEC as well as OrchardZSA transfer actions for Custom Assets.
+The formula for the computation of the + \(zsa\_logical\_actions\) + (with the updated computation of + \(logical\_actions\) + as described above) is:
+The formula for the computation of the + \(zsa\_conventional\_fee\) + is:
+It is not a consensus requirement that fees follow this formula; however, wallets SHOULD create transactions that pay this fee, in order to reduce information leakage, unless overridden by the user.
+The OrchardZSA fee calculation accounts for the additions to the Global Issuance State that are required for the OrchardZSA protocol. Every newly created Custom Asset adds a new row to the Global Issuance State. Subsequent issuance, finalization, or burn of existing Custom Assets only changes the values in the corresponding row.
+This explains the need for a higher fee for the creation of entirely new Custom Assets, in order to disincentivize the creation of "junk" assets.
+We choose to maintain the native ZEC Asset as the primary token for the Zcash blockchain, similar to how ETH is needed for ERC20 transactions to the benefit of the Ethereum ecosystem.
+An alternative proposal for the OrchardZSA fee mechanism that was not adopted was to adopt a new type of fee, denominated in the custom Asset being issued or transferred. In the context of transparent transactions, such a fee allows miners to “tap into” the ZSA value of the transactions, rather than the ZEC value of transactions. However when transactions are shielded, any design that lifts value from the transaction would also leak information about it.
+TODO
6 | +Zcash Protocol Specification, Version 2022.3.8. Section 7.1: Transaction Encoding and Consensus | +
---|
7 | ZIP 226: Transfer and Burn of Zcash Shielded Assets |
---|
7 | +8 | ZIP 227: Issuance of Zcash Shielded Assets |
---|
8 | +9 | ZIP 244: Transaction Identifier Non-Malleability |
---|
10 | +ZIP 317: Proportional Transfer Fee Mechanism | +
---|
11 | +ZIP 317: Proportional Transfer Fee Mechanism, Fee calculation | +
---|