Skip to content

[ZIP 230, ZIP 246] v6 transaction format and sighash#987

Merged
nuttycom merged 30 commits into
mainfrom
v6-tx-format-and-sighash
May 20, 2025
Merged

[ZIP 230, ZIP 246] v6 transaction format and sighash#987
nuttycom merged 30 commits into
mainfrom
v6-tx-format-and-sighash

Conversation

@str4d
Copy link
Copy Markdown
Collaborator

@str4d str4d commented Feb 26, 2025

Incomplete todo list:

  • Specify sighash versioning process (it is currently just a rough summary).

@str4d str4d marked this pull request as draft February 26, 2025 23:13
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
clean up some formatting.

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
Copy link
Copy Markdown
Contributor

@vivek-arte vivek-arte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the changes relevant for the sighash and transaction format is the move of the burn field information into the action groups.

Note that this is independent of any subsequent versioning etc for Swaps specific changes, it is natural to have the burn information a part of each Action Group.

I've made those changes as suggestions in this review, along with a few smaller suggestions.

Comment thread zips/zip-0227.rst Outdated
Comment thread zips/zip-0230.rst Outdated
Comment thread zips/zip-0230.rst
Comment thread zips/zip-0230.rst Outdated
Comment thread zips/zip-0246.rst Outdated
Comment thread zips/zip-0246.rst
Comment thread zips/zip-0246.rst Outdated
Comment thread zips/zip-0226.rst Outdated
Co-authored-by: Vivek Arte <46618816+vivek-arte@users.noreply.github.com>
Comment thread zips/zip-0227.rst Outdated
Comment thread zips/zip-0246.rst
- Sighash versions are numbered starting from 0 for each tx version.
- v0 is by convention the "commit to everything" sighash digest. Other versions can commit to whatever makes sense for desired functionality within that tx version.
- Have a single byte encoded alongside the signature (not appended the way transparent does) that permits the signer to specify which sighash version they are using.
- Consensus rules choose the digest algorithm for each signer based on that byte.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should clarify that the consensus rules choose from the available digest algorithms for the (consensus_branch_id, transaction_version) tuple under question (both of which are committed to by the transaction, and can therefore be checked non-contextually). For the NU7 consensus branch ID, there will only be one available digest version for v6 transactions (the v0 digests).

Comment thread zips/zip-0246.rst

- Sighash versions are numbered starting from 0 for each tx version.
- v0 is by convention the "commit to everything" sighash digest. Other versions can commit to whatever makes sense for desired functionality within that tx version.
- Have a single byte encoded alongside the signature (not appended the way transparent does) that permits the signer to specify which sighash version they are using.
Copy link
Copy Markdown
Collaborator Author

@str4d str4d Mar 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In ZIP Sync, we discussed how this should be represented. We identified that one of the issues we have with how transparent sighash types are handled is that they are considered authorizing data (they are appended to signatures and are thus part of the signature, chosen at signing time by the signer). We decided that for sighash versioning, we'd prefer them to be effecting data. This means:

  • For Sapling spendAuthSig, this would be an extra byte on the Spend Description.
  • For Orchard spendAuthSig, this would be an extra byte on the Action Description.
  • For bindingSigs, we place an extra byte in the corresponding bundles.
  • For transparent, due to the lack of a 1:1 between inputs and signatures (as an arbitrary number of signatures can exist within a scriptSig), this would be an extra byte on the CTxIn that is used for every signature authorizing the input.
    • @daira doesn't think we need it at the per-input level for transparent (Ya Ain't Gonna Need It), while @str4d says this is useful for symmetry (the effecting data is then consistently at the per-input level) and that we are trying to create a design that doesn't restrict what kinds of sighash digest algorithms we might want to create in future. @nuttycom is happy to have it at the per-input level for now, and we can adjust if we discover difficulties.
    • Note that there is no requirement for future sighash digest algorithms to pay any attention to the sighash_type appended to each signature. It is entirely fine for us to treat that as a v0-specific behaviour (or even decide to phase it out in future transaction versions, though we are explicitly choosing to keep it for the v6 transaction's v0 digest algorithm).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rather strongly don't want very much if any additional complexity or work associated with transparent features.

Comment thread zips/zip-0230.rst
Comment on lines +286 to +287
| 1 |``flagsOrchard`` |``byte`` |As defined in Section 7.1 of the Protocol Specification |
| | | |[#protocol-txnencoding]_. |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should reference ZIP 225, or a more precise reference within the protocol spec, instead of section 7.1.

Comment thread zips/zip-0230.rst
@@ -222,86 +203,111 @@ Transaction Format

Copy link
Copy Markdown
Collaborator

@daira daira Apr 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At line 191, change SpendDescriptionV6 to SpendDescriptionV5, and add an extra bullet point:

* There is no ``SpendDescriptionV6`` because the format of Sapling Spend descriptions
  has not changed from ``SpendDescriptionV5`` [#zip-0225]_.

Comment thread zips/zip-0230.rst
@@ -315,31 +321,39 @@ We introduce the ``nAGExpiryHeight`` field in this transaction format in order t
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.
Copy link
Copy Markdown
Contributor

@nuttycom nuttycom Apr 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to ensure that a conformance requirement exists within the specification that requires nAGExpiryHeight to be zero as of NU7.

However, the consistency between nAGExpiryHeight and the overall transaction expiry height should be specified here (though not in the rationale section.)

Comment thread zips/zip-0230.rst Outdated
@nuttycom nuttycom force-pushed the v6-tx-format-and-sighash branch from 2755ae9 to a5b5756 Compare April 30, 2025 00:02
@nuttycom nuttycom marked this pull request as ready for review April 30, 2025 00:02
Comment thread zips/zip-0246.rst Outdated
Comment thread zips/zip-0246.rst Outdated
Comment thread zips/zip-0246.rst Outdated
@arya2 arya2 self-requested a review May 6, 2025 22:35
Reviewed with @str4d, @arya, @SamHSmith

Co-authored-by: Vivek Arte <46618816+vivek-arte@users.noreply.github.com>
@str4d str4d force-pushed the v6-tx-format-and-sighash branch from a5b5756 to 2225f87 Compare May 13, 2025 23:10
@str4d
Copy link
Copy Markdown
Collaborator Author

str4d commented May 13, 2025

Force-pushed to undo the render, and fix my review comments.

Comment thread zips/zip-0230.rst
``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.
* If thee value of ``nAGExpiryHeight`` is nonzero, it MUST be consistent with
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* If thee value of ``nAGExpiryHeight`` is nonzero, it MUST be consistent with
* If the value of ``nAGExpiryHeight`` is nonzero, it MUST be consistent with

Comment thread README.template
Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor

@nuttycom nuttycom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK for interim merge; there will be follow-up PRs for ZIP 246 regardless.

Comment thread zips/zip-0230.rst
+-----------------------------+------------------------------+------------------------------------------------+---------------------------------------------------------------------+
| 8 |``fee`` |``uint64`` |The fee to be paid by this transaction, in zatoshis. |
+-----------------------------+------------------------------+------------------------------------------------+---------------------------------------------------------------------+
| 8 |``burnAmount`` |``uint64`` |The value to be burned in this transaction, in zatoshis. |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Is this field name changing, or are we still calling it "burning"?

Comment thread zips/zip-0230.rst
| 32 |``AssetBase`` |``byte[32]`` |For the OrchardZSA protocol, this is the encoding of the Asset Base |
| | | |:math:`\mathsf{AssetBase^{Orchard}}\!`. |
+-----------------------------+------------------------------+------------------------------------------------+---------------------------------------------------------------------+
| 8 |``valueBurn`` |``uint64`` |The amount being burnt. The value is checked by consensus to be |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this is a burn, in contrast to the ZSF deposit, I think it's important to have different naming.

Comment thread zips/zip-0246.rst
Comment on lines +247 to +248
T.4a.i : orchard_actions_compact_digest (32-byte hash output)
T.4a.ii : orchard_actions_noncompact_digest (32-byte hash output)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: all that we need here is the noncompact digest.

Comment thread zips/zip-0246.rst
Comment on lines +181 to +182
T.3b.i: sapling_outputs_compact_digest (32-byte hash)
T.3b.ii: sapling_outputs_noncompact_digest (32-byte hash)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: all we need is the noncompact digest.

Comment thread zips/zip-0230.rst
+-----------------------------+------------------------------+------------------------------------------------+---------------------------------------------------------------------+
| 8 |``fee`` |``uint64`` |The fee to be paid by this transaction, in zatoshis. |
+-----------------------------+------------------------------+------------------------------------------------+---------------------------------------------------------------------+
| 8 |``burnAmount`` |``uint64`` |The value to be burned in this transaction, in zatoshis. |
Copy link
Copy Markdown
Contributor

@nuttycom nuttycom May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| 8 |``burnAmount`` |``uint64`` |The value to be burned in this transaction, in zatoshis. |
| 8 |``zip233Amount`` |``uint64`` |The value to be removed from circulation in this transaction, in |
| | | |zatoshis. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change can be made in a future PR, to avoid foramtting issues.

@nuttycom nuttycom merged commit 9e647aa into main May 20, 2025
1 check passed
@nuttycom nuttycom deleted the v6-tx-format-and-sighash branch May 20, 2025 21:11
vivek-arte added a commit to QED-it/zips that referenced this pull request Sep 2, 2025
The merge of zcash#987 happened to delete the table entry for the Asset Base
in the Issue Note. We are adding it back here.
ConstanceBeguier added a commit to QED-it/librustzcash that referenced this pull request Sep 23, 2025
This PR performs the change from zcash/zips#987
to remove the asset base from the issue note description. It also makes
the follow-on reorderings suggested in
zcash/zips#1086 and
zcash/zips#1088.

The test vectors are updated in
QED-it/zcash-test-vectors#36 and copied in from
there.

---------

Co-authored-by: Constance Beguier <constance@qed-it.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants