Skip to content

Add Orchard versioned signatures and add ALGORITHM_BYTE to ik and IssueAuthSig#129

Merged
ConstanceBeguier merged 21 commits intozsa1from
orchard_sighash_version
Sep 16, 2025
Merged

Add Orchard versioned signatures and add ALGORITHM_BYTE to ik and IssueAuthSig#129
ConstanceBeguier merged 21 commits intozsa1from
orchard_sighash_version

Conversation

@ConstanceBeguier
Copy link

@ConstanceBeguier ConstanceBeguier commented Aug 21, 2025

Add SighashVersion (version and associated data) to

  • Orchard binding signatures,
  • Orchard authorizing signatures, and
  • issuance authorization signatures

as defined in ZIP-246

Add ALGORITHM_BYTE to ik and IssueAuthSig as defined in ZIP-227.

Update test vectors

@QED-it QED-it deleted a comment from what-the-diff bot Aug 21, 2025
@ConstanceBeguier ConstanceBeguier changed the title Add orchard sighash version Add Orchard sighash version Aug 24, 2025
@ConstanceBeguier ConstanceBeguier changed the title Add Orchard sighash version Add Orchard SighashInfo Sep 1, 2025
@ConstanceBeguier ConstanceBeguier changed the title Add Orchard SighashInfo Add versioned signatures Sep 4, 2025
@ConstanceBeguier ConstanceBeguier changed the title Add versioned signatures Add Orchard versioned signatures Sep 5, 2025
@ConstanceBeguier ConstanceBeguier changed the title Add Orchard versioned signatures Add Orchard versioned signatures and add ALGORITHM_BYTE to ik and IssueAuthSig Sep 11, 2025
Copy link
Collaborator

@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.

overall good. added comments

Comment on lines +209 to +215
#[serde_as]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub(crate) struct VerSpendAuthSig {
pub(crate) sighash_info: Vec<u8>,
#[serde_as(as = "[_; 64]")]
pub(crate) signature: [u8; 64],
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we import the entire struct from Orchard?
If not, the struct should be properly documented

Copy link
Author

Choose a reason for hiding this comment

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

It is not exactly the same struct than the struct in Orchard.
In Orchard the signature is a redpallas signature and not a [u8; 64].
My implementation is inspired by the Zip32Derivation struct which differs between Orchard and librustzcash/pczt.

0x01, 0x01, 0x52, 0x66, 0xf9, 0xef, 0xd5, 0xcf, 0x90, 0x7d, 0x79, 0x3d, 0xab,
0x9b, 0x1c, 0xd6, 0x4f, 0x86, 0x6b, 0x61, 0xa2, 0x98, 0x59, 0x53, 0x93, 0xf0,
0x71, 0x53, 0xa6, 0xb9, 0x17, 0x13, 0x61, 0xa2, 0x8a, 0x53, 0x51, 0xfc, 0x49,
0x3d, 0x15, 0x4a, 0x75, 0xe1, 0x29, 0xfe, 0xac, 0x9b, 0x67, 0x58, 0x17, 0xb8,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

The content is the same but the indentation makes it hard to see.

Copy link
Author

Choose a reason for hiding this comment

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

I removed mod orchard_zsa_digests to reduce indentation.

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub(crate) struct VerSpendAuthSig {
pub(crate) sighash_info: Vec<u8>,
#[serde_as(as = "[_; 64]")]
Copy link
Collaborator

Choose a reason for hiding this comment

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

the only similar thing we have in this project is

    /// The spend authorization signature.
    ///
    /// This is set by the Signer.
    #[serde_as(as = "Option<[_; 64]>")]
    pub(crate) spend_auth_sig: Option<[u8; 64]>,

Is this consistent with the semantics of Option<_> for spend_auth_sig?

Copy link
Author

Choose a reason for hiding this comment

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

Now we have a spend auth sig which contains two different fields the sighash version and the signature.
So, spend_auth_sig contains an Option and VerSpendAuthSig contains the sighash version and the signature.
It is similar to pub(crate) zip32_derivation: Option<Zip32Derivation>

The attribute #[serde_as(as = "[_; 64]")] tells serde_with to serialize and deserialize the [u8; 64] field as a fixed-size array of 64 elements, since Serde alone does not natively support arrays larger than 32 elements.

Comment on lines +272 to +276
Ok(VersionedSig::<Signature<T>>::new(
SIGHASH_V0,
Signature::from(bytes),
))
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

how do we ensure that this does not break v5?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Alternatively, we can keep this function as is and use it just for v5.

Copy link
Author

Choose a reason for hiding this comment

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

As discussed, we will keep my implementation.

@ConstanceBeguier ConstanceBeguier merged commit 7cc2789 into zsa1 Sep 16, 2025
46 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