-
Notifications
You must be signed in to change notification settings - Fork 177
[ZIP 230, ZIP 246] v6 transaction format and sighash #987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
8862ae2
ZIP 230: Reorganise `ActionGroupDescription` to group effecting data
str4d cdf76fb
ZIP 230: Constrain parser for `nAGExpiryHeight` and clarify `0`
str4d 80ac162
ZIP 230: Remove AssetBase from issuance bundle encoding
str4d c0c20fb
ZIP 246: Initial empty ZIP structure for v6 transaction digests
str4d 7a112c7
Updating digest names (#95)
vivek-arte a34a5eb
Move-only: Move sighash content from ZIP 226 to ZIP 246
str4d 5ab748a
Move-only: Move sighash content from ZIP 227 to ZIP 246
str4d 457a04c
Replace moved content in ZIPs 226 and 227 with a reference
str4d f44713e
ZIP 246: Refer to ZIP 230 for field encodings
str4d 8df0c17
ZIP 246: Fix heading levels and a bug from #975
str4d dba350f
ZIP 246: Remove `_zsa` internal suffix from digest names
str4d 5ec91f9
Integrate ZIP 231 changes into ZIPs 230 and 246
str4d 07fa7c3
Integrate ZIPs 233 and 2002 into ZIPs 230 and 246
str4d 2220b35
Clear out some trailing whitespace
str4d aa7436e
ZIP 317: Fix rendering of conventional fee formula
daira 39d74ed
ZIP 317: Integrate fee changes from ZIP 227
str4d b0d8fbd
ZIP 317: Integrate fee changes from ZIP 231
str4d edba0a0
Improve formatting of ZIP 317.
daira 001cdd8
ZIP 230: make all the table columns the same width in the source, and
daira 3d6f118
Apply minor editorial suggestions
daira e9369af
adding the rst changes for the addition of burn fields into the Actio…
vivek-arte 91a8e53
fixing order of fields in Action Group
vivek-arte 4a419cf
Apply suggestions to ZIP 246 from ZIP review
vivek-arte 2258c31
adding rationale for the placement of burn fields inside Action Groups
vivek-arte bb69fe9
updating TxId Digest tree
vivek-arte e978277
moving the rationale for the burn field positioning inside action gro…
vivek-arte ffc4c32
Merge pull request #991 from QED-it/adding_burn_to_ag_987
str4d 2225f87
Apply suggestions from code review
nuttycom 86ffb0f
Merge branch 'main' into v6-tx-format-and-sighash
str4d 936571a
Merge branch 'main' into v6-tx-format-and-sighash
str4d File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -345,206 +345,14 @@ OrchardZSA Transaction Structure | |
| The transaction format for v6 transactions is described in ZIP 230 [#zip-0230]_. | ||
|
|
||
|
|
||
| TxId Digest | ||
| =========== | ||
|
|
||
| The transaction digest algorithm defined in ZIP 244 [#zip-0244]_ is modified by the OrchardZSA 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 OrchardZSA protocol. | ||
|
|
||
| txid_digest | ||
| ----------- | ||
| A BLAKE2b-256 hash of the following values:: | ||
|
|
||
| T.1: header_digest (32-byte hash output) | ||
| T.2: transparent_digest (32-byte hash output) | ||
| 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 [#zip-0244]_. | ||
|
|
||
| T.4: orchard_digest | ||
| ``````````````````` | ||
| When OrchardZSA Actions Groups are present in the transaction, this digest is a BLAKE2b-256 hash of the following values:: | ||
|
|
||
| T.4a: orchard_action_groups_digest (32-byte hash output) [ADDED FOR ZSA] | ||
| T.4b: orchard_zsa_burn_digest (32-byte hash output) [ADDED FOR ZSA] | ||
| T.4c: valueBalanceOrchard (64-bit signed little-endian) | ||
|
|
||
| The personalization field of this hash is the same as in ZIP 244 [#zip-0244]_ :: | ||
|
|
||
| "ZTxIdOrchardHash" | ||
|
|
||
| In the case that the transaction has no OrchardZSA Action Groups, ``orchard_digest`` is :: | ||
|
|
||
| BLAKE2b-256("ZTxIdOrchardHash", []) | ||
|
|
||
| T.4a: orchard_action_groups_digest | ||
| '''''''''''''''''''''''''''''''''' | ||
|
|
||
| A BLAKE2b-256 hash of the subset of OrchardZSA Action Groups information for all OrchardZSA Action Groups belonging to the transaction. | ||
| For each Action Group, the following elements are included in the hash:: | ||
|
|
||
| T.4a.i : orchard_actions_compact_digest (32-byte hash output) | ||
| T.4a.ii : orchard_actions_memos_digest (32-byte hash output) | ||
| T.4a.iii: orchard_actions_noncompact_digest (32-byte hash output) | ||
| T.4a.iv : flagsOrchard (1 byte) | ||
| T.4a.v : anchorOrchard (32 bytes) | ||
| T.4a.vi : nAGExpiryHeight (4 bytes) | ||
|
|
||
| The personalization field of this hash is set to:: | ||
|
|
||
| "ZTxIdOrcActGHash" | ||
|
|
||
|
|
||
| T.4a.i: orchard_actions_compact_digest | ||
| ...................................... | ||
|
|
||
| A BLAKE2b-256 hash of the subset of OrchardZSA Action information intended to be included in | ||
| an updated version of the ZIP-307 [#zip-0307]_ ``CompactBlock`` format for all OrchardZSA | ||
| Actions belonging to the Action Group. For each Action, the following elements are included | ||
| in the hash:: | ||
|
|
||
| T.4a.i.1 : nullifier (field encoding bytes) | ||
| T.4a.i.2 : cmx (field encoding bytes) | ||
| T.4a.i.3 : ephemeralKey (field encoding bytes) | ||
| T.4a.i.4 : encCiphertext[..84] (First 84 bytes of field encoding) [UPDATED FOR ZSA] | ||
|
|
||
| The personalization field of this hash is the same as in ZIP 244:: | ||
|
|
||
| "ZTxIdOrcActCHash" | ||
|
|
||
|
|
||
| T.4a.ii: orchard_actions_memos_digest | ||
| ..................................... | ||
|
|
||
| A BLAKE2b-256 hash of the subset of Orchard shielded memo field data for all OrchardZSA | ||
| Actions belonging to the Action Group. For each Action, the following elements are included | ||
| in the hash:: | ||
|
|
||
| T.4a.ii.1: encCiphertext[84..596] (contents of the encrypted memo field) [UPDATED FOR ZSA] | ||
|
|
||
| The personalization field of this hash remains identical to ZIP 244:: | ||
|
|
||
| "ZTxIdOrcActMHash" | ||
|
|
||
|
|
||
| T.4a.iii: orchard_actions_noncompact_digest | ||
| ........................................... | ||
|
|
||
| A BLAKE2b-256 hash of the remaining subset of OrchardZSA Action information **not** intended | ||
| for inclusion in an updated version of the the ZIP 307 [#zip-0307]_ ``CompactBlock`` | ||
| format, for all OrchardZSA Actions belonging to the Action Group. For each Action, | ||
| the following elements are included in the hash:: | ||
|
|
||
| T.4a.iii.1 : cv (field encoding bytes) | ||
| T.4a.iii.2 : rk (field encoding bytes) | ||
| T.4a.iii.3 : encCiphertext[596..] (post-memo suffix of field encoding) [UPDATED FOR ZSA] | ||
| T.4a.iii.4 : outCiphertext (field encoding bytes) | ||
|
|
||
| The personalization field of this hash is defined identically to ZIP 244:: | ||
|
|
||
| "ZTxIdOrcActNHash" | ||
|
|
||
|
|
||
| T.4b: orchard_zsa_burn_digest | ||
| ''''''''''''''''''''''''''''' | ||
|
|
||
| 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.4b.i : assetBase (field encoding bytes) | ||
| T.4b.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", []) | ||
|
|
||
| T.4b.i: assetBase | ||
| ................. | ||
| The Asset Base being burnt encoded as the 32-byte representation of a point on the | ||
| Pallas curve. | ||
|
|
||
| T.4b.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]_. | ||
|
|
||
| Signature Digest | ||
| ================ | ||
|
|
||
| The details of the changes to this algorithm are in ZIP 227 [#zip-0227-sigdigest]_. | ||
|
|
||
| Authorizing Data Commitment | ||
| =========================== | ||
|
|
||
| The transaction digest algorithm defined in ZIP 244 [#zip-0244-authcommitment]_ which commits to the authorizing data of a transaction is modified by the OrchardZSA protocol to have the structure specified in this section. | ||
| There is a new branch added for issuance information, along with modifications within the ``orchard_auth_digest`` to account for the presence of Action Groups. | ||
|
|
||
| We highlight the changes for the OrchardZSA protocol via the ``[UPDATED FOR ZSA]`` or ``[ADDED FOR ZSA]`` text label, and we omit the descriptions of the sections that do not change for the OrchardZSA protocol:: | ||
|
|
||
| auth_digest | ||
| ├── transparent_scripts_digest | ||
| ├── sapling_auth_digest | ||
| ├── orchard_auth_digest [UPDATED FOR ZSA] | ||
| └── issuance_auth_digest [ADDED FOR ZSA] | ||
|
|
||
| The pair (Transaction Identifier, Auth Commitment) constitutes a commitment to all the data of a serialized transaction that may be included in a block. | ||
|
|
||
| auth_digest | ||
| ----------- | ||
| A BLAKE2b-256 hash of the following values :: | ||
|
|
||
| A.1: transparent_scripts_digest (32-byte hash output) | ||
| A.2: sapling_auth_digest (32-byte hash output) | ||
| A.3: orchard_auth_digest (32-byte hash output) [UPDATED FOR ZSA] | ||
| A.4: issuance_auth_digest (32-byte hash output) [ADDED FOR ZSA] | ||
|
|
||
| The personalization field of this hash remains the same as in ZIP 244. | ||
|
|
||
|
|
||
| A.3: orchard_auth_digest | ||
| ```````````````````````` | ||
|
|
||
| In the case that OrchardZSA Action Groups are present, this is a BLAKE2b-256 hash of the following values:: | ||
|
|
||
| A.3a: orchard_action_groups_auth_digest (32-byte hash output) [ADDED FOR ZSA] | ||
| A.3b: bindingSigOrchard (field encoding bytes) | ||
|
|
||
| The personalization field of this hash is the same as in ZIP 244, that is:: | ||
|
|
||
| "ZTxAuthOrchaHash" | ||
|
|
||
| In case that the transaction has no OrchardZSA Action Groups, ``orchard_auth_digest`` is:: | ||
|
|
||
| BLAKE2b-256("ZTxAuthOrchaHash", []) | ||
|
|
||
| A.3a: orchard_action_groups_auth_digest | ||
| ''''''''''''''''''''''''''''''''''''''' | ||
|
|
||
| This is a BLAKE2b-256 hash of the ``proofsOrchard`` and ``spendAuthSigsOrchard`` fields of all OrchardZSA Action Groups belonging to the transaction:: | ||
|
|
||
| A.3a.i: proofsOrchard (field encoding bytes) | ||
| A.3a.ii: spendAuthSigsOrchard (field encoding bytes) | ||
|
|
||
| The personalization field of this hash is set to:: | ||
|
|
||
| "ZTxAuthOrcAGHash" | ||
|
|
||
| A.4: issuance_auth_digest | ||
| ````````````````````````` | ||
| Modifications relative to ZIP 244 [#zip-0244]_ | ||
| ============================================== | ||
|
|
||
| The details of the computation of this value are in ZIP 227 [#zip-0227-authcommitment]_. | ||
| Relative to the sighash algorithm defined in ZIP 244 [#zip-0244]_, the sighash algorithm | ||
| that applies to v6 transactions differs by altering the Orchard bundle within | ||
| the tree hash to match the corresponding OrchardZSA changes. See ZIP 246 [#zip-0246]_ | ||
| for details. | ||
|
|
||
|
|
||
| Security and Privacy Considerations | ||
|
|
@@ -604,12 +412,11 @@ References | |
| .. [#zip-0227-consensus] `ZIP 227: Issuance of Zcash Shielded Assets: Specification: Consensus Rule Changes <zip-0227.html#specification-consensus-rule-changes>`_ | ||
| .. [#zip-0227-note-commitment-order] `ZIP 227: Issuance of Zcash Shielded Assets: Addition to the Note Commitment Tree <zip-0227.html#addition-to-the-note-commitment-tree>`_ | ||
| .. [#zip-0227-txiddigest] `ZIP 227: Issuance of Zcash Shielded Assets: TxId Digest - Issuance <zip-0227.html#txid-digest-issuance>`_ | ||
| .. [#zip-0227-sigdigest] `ZIP 227: Issuance of Zcash Shielded Assets: Signature Digest <zip-0227.html#signature-digest>`_ | ||
| .. [#zip-0227-authcommitment] `ZIP 227: Issuance of Zcash Shielded Assets: Authorizing Data Commitment <zip-0227.html#authorizing-data-commitment-issuance>`_ | ||
| .. [#zip-0227-orchardzsa-fee-calculation] `ZIP 227: Issuance of Zcash Shielded Assets: OrchardZSA Fee Calculation <zip-0227.html#orchardzsa-fee-calculation>`_ | ||
| .. [#zip-0230] `ZIP 230: Version 6 Transaction Format <zip-0230.html>`_ | ||
| .. [#zip-0244] `ZIP 244: Transaction Identifier Non-Malleability <zip-0244.html>`_ | ||
| .. [#zip-0244-authcommitment] `ZIP 244: Transaction Identifier Non-Malleability: Authorizing Data Commitment <zip-0244.html#authorizing-data-commitment>`_ | ||
| .. [#zip-0246] `ZIP 246: Digests for the Version 6 Transaction Format <zip-0246.html>`_ | ||
|
Comment on lines
412
to
+419
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW it is preferred for the URL to reference the source file (the link will be updated in the rendered HTML). |
||
| .. [#zip-0307] `ZIP 307: Light Client Protocol for Payment Detection <zip-0307.rst>`_ | ||
| .. [#protocol-notes] `Zcash Protocol Specification, Version 2024.5.1 [NU6]. Section 3.2: Notes <protocol/protocol.pdf#notes>`_ | ||
| .. [#protocol-actions] `Zcash Protocol Specification, Version 2024.5.1 [NU6]. Section 3.7: Action Transfers and their Descriptions <protocol/protocol.pdf#actions>`_ | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also regenerate
README.rst.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that the .rst generation should be a blocker for PRs merging; having CI do the publishing ensures that the zips.z.cash render is up to date, and regenerating the .rst can be done opportunistically, out-of-band. We will not expect third-party contributors to do this regeneration, in any case.