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] 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) |
---|