Skip to content

Add versioned signatures for Transparent transactions#35

Merged
ConstanceBeguier merged 5 commits into
zsa1from
transparent_sighash_info
Nov 3, 2025
Merged

Add versioned signatures for Transparent transactions#35
ConstanceBeguier merged 5 commits into
zsa1from
transparent_sighash_info

Conversation

@ConstanceBeguier
Copy link
Copy Markdown

@ConstanceBeguier ConstanceBeguier commented Sep 9, 2025

Add SighashInfo (version and associated data) to

  • Transparent authorizing signatures.

Update auth_digest by adding SighashInfo as defined in ZIP246

Add SighashInfo for Sapling/Orchard binding signatures only when the signatures exist

@ConstanceBeguier ConstanceBeguier changed the title Transparent sighash info Add versioned signatures for Transparent transactions Sep 11, 2025
@ConstanceBeguier ConstanceBeguier force-pushed the transparent_sighash_info branch 2 times, most recently from cc631d8 to 34db9e9 Compare September 11, 2025 12:22
@ConstanceBeguier ConstanceBeguier force-pushed the sapling_sighash_info branch 2 times, most recently from da2f267 to 8c2eab9 Compare October 2, 2025 11:35
@ConstanceBeguier ConstanceBeguier force-pushed the transparent_sighash_info branch from 34db9e9 to f3d9ef6 Compare October 29, 2025 15:27
@ConstanceBeguier ConstanceBeguier changed the base branch from sapling_sighash_info to zsa1 October 29, 2025 15:30
PaulLaux
PaulLaux previously approved these changes Nov 2, 2025
Copy link
Copy Markdown

@PaulLaux PaulLaux left a comment

Choose a reason for hiding this comment

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

Approved with minor comments

Comment thread zcash_test_vectors/zip_0244.py Outdated

def transparent_scripts_digest_v6(tx):
digest = blake2b(digest_size=32, person=TRANSPARENT_AUTH_DIGEST_PERSONALIZAION)
for (sighash_info, x) in zip(tx.vSighashInfo, tx.vin):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

replace x with vin

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

Comment on lines +155 to +158
if hasattr(self, "bindingSigSapling"):
self.bindingSigSaplingInfo = sighash_info
if hasattr(self, "bindingSigOrchard"):
self.bindingSigOrchardInfo = sighash_info
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Later, in

        for desc in tx.vOutputsSapling:
            digest.update(bytes(desc.proof))
        digest.update(write_compact_size(len(tx.bindingSigSaplingInfo)))
        digest.update(bytes(tx.bindingSigSaplingInfo))
        digest.update(bytes(tx.bindingSigSapling))

what happens if tx.bindingSigSaplingInfo in None?

Copy link
Copy Markdown
Author

@ConstanceBeguier ConstanceBeguier Nov 3, 2025

Choose a reason for hiding this comment

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

def sapling_auth_digest_v6(tx):
    digest = blake2b(digest_size=32, person=SAPLING_AUTH_DIGEST_PERSONALIZAION)

    if len(tx.vSpendsSapling) + len(tx.vOutputsSapling) > 0:
        for desc in tx.vSpendsSapling:
            digest.update(bytes(desc.proof))
        for desc in tx.vSpendsSapling:
            digest.update(write_compact_size(len(desc.spendAuthSigInfo)))
            digest.update(bytes(desc.spendAuthSigInfo))
            digest.update(bytes(desc.spendAuthSig))
        for desc in tx.vOutputsSapling:
            digest.update(bytes(desc.proof))
        digest.update(write_compact_size(len(tx.bindingSigSaplingInfo)))
        digest.update(bytes(tx.bindingSigSaplingInfo))
        digest.update(bytes(tx.bindingSigSapling))

    return digest.digest()

If tx.bindingSigSaplingInfo is None and we try to access it, an exception will be raised.
The function sapling_auth_digest_v6 is only called for v6 transaction.
In this function, tx.bindingSigSaplingInfo and tx.bindingSigSapling are accessed only when the transaction includes a Sapling element.
For v6 transactions, whenever a Sapling element is present, both of these fields are populated.

@ConstanceBeguier ConstanceBeguier merged commit f022e36 into zsa1 Nov 3, 2025
3 checks passed
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.

2 participants