Conversation
PR Summary
|
61ecd79 to
8b371c5
Compare
4a25598 to
a8d34b1
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR updates the encoding of the issuance validating key (ik) and issuance authorization signature (issueAuthSig) by changing their serialization format to include a leading algorithm identifier byte, following the specification changes in zcash/zips#1042.
- Updated
ikencoding from 32 to 33 bytes with a 0x00 prefix byte - Updated
issueAuthSigencoding from 64 to 65 bytes with a 0x00 prefix byte - Modified test vectors to reflect the new encoding format
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test_vectors/keys.rs | Updated all test vectors for ik field from 32 to 33 bytes with 0x00 prefix |
| src/test_vectors/issuance_auth_sig.rs | Updated test vectors for both ik and sig fields with new encoding format |
| src/test_vectors/asset_base.rs | Updated test vectors for key field and corresponding asset_base values |
| src/note/asset_base.rs | Modified asset_digest function and AssetBase::derive to handle 66-byte asset IDs |
| src/keys.rs | Added issuance signature scheme infrastructure and updated key/signature encoding |
| src/issuance.rs | Added IssuanceAuthorizationSignature struct with scheme-aware encoding |
| src/bundle/commitments.rs | Updated hash computation to use new signature byte encoding |
| CannotBeFirstIssuance, | ||
|
|
||
| /// The generation of the Issuance Authorization Signature failed. | ||
| IssueAuthSigGenerationFailed, //TODO: VA: This does not propagate the schnorr::Error, fix it. |
There was a problem hiding this comment.
The TODO comment indicates incomplete error handling. Consider either implementing proper error propagation from schnorr::Error or removing the TODO if this is intentional for now.
| pub fn to_bytes(&self) -> Vec<u8> { | ||
| let mut bytes = vec![self.scheme as u8]; | ||
| bytes.extend(self.key.to_bytes()); |
There was a problem hiding this comment.
Returning Vec for key serialization is inconsistent with other key types that return fixed-size arrays. Consider returning a fixed-size array like [u8; 33] for better type safety and consistency.
| pub fn to_bytes(&self) -> Vec<u8> { | |
| let mut bytes = vec![self.scheme as u8]; | |
| bytes.extend(self.key.to_bytes()); | |
| pub fn to_bytes(&self) -> [u8; 33] { | |
| let mut bytes = [0u8; 33]; | |
| bytes[0] = self.scheme as u8; | |
| bytes[1..].copy_from_slice(&self.key.to_bytes()); |
| pub fn to_bytes(&self) -> Vec<u8> { | ||
| let mut bytes = vec![self.scheme as u8]; | ||
| bytes.extend(self.signature.to_bytes()); |
There was a problem hiding this comment.
Similar to IssuanceValidatingKey, returning Vec instead of a fixed-size array reduces type safety. Consider returning [u8; 65] for consistency with the scheme's defined signature length.
| pub fn to_bytes(&self) -> Vec<u8> { | |
| let mut bytes = vec![self.scheme as u8]; | |
| bytes.extend(self.signature.to_bytes()); | |
| pub fn to_bytes(&self) -> [u8; 65] { | |
| let mut bytes = [0u8; 65]; | |
| bytes[0] = self.scheme as u8; | |
| bytes[1..].copy_from_slice(&self.signature.to_bytes()); |
| } | ||
|
|
||
| /// Constructs an `IssuanceAuthorizationSignature` from a byte array. | ||
| pub fn from_bytes(bytes: &[u8; 65]) -> Result<Self, Error> { |
There was a problem hiding this comment.
Replace [u8; 65] with [u8] or Vec because the length of the sig depends on the scheme
| #[derive(Debug, Clone, PartialEq, Eq)] | ||
| pub struct IssuanceAuthorizationSignature { | ||
| scheme: IssuanceAuthSigScheme, | ||
| signature: schnorr::Signature, |
There was a problem hiding this comment.
I think signature should be a [u8] or Vec because we would like to have a generic implementation which might not be a Schnorr signature
| } | ||
|
|
||
| /// Returns the signature. | ||
| pub fn signature(&self) -> &schnorr::Signature { |
There was a problem hiding this comment.
Idem
This function should return &[u8] or &Vec
| let scheme = IssuanceAuthSigScheme::from_key_algorithm_byte(bytes[0]) | ||
| .ok_or(IssueBundleInvalidSignature)?; | ||
| let signature = | ||
| schnorr::Signature::try_from(&bytes[1..]).map_err(|_| IssueBundleInvalidSignature)?; |
There was a problem hiding this comment.
The signature might not be the Schnorr signature
|
|
||
| /// Constructs a `Signed` from a byte array containing Schnorr signature bytes. | ||
| pub fn from_data(data: [u8; 64]) -> Self { | ||
| pub fn from_data(data: [u8; 65]) -> Self { |
There was a problem hiding this comment.
Replace [u8; 65] with [u8] or Vec because the length of the sig depends on the scheme
| pub struct IssuanceValidatingKey(schnorr::VerifyingKey); | ||
| pub struct IssuanceValidatingKey { | ||
| scheme: IssuanceAuthSigScheme, | ||
| key: schnorr::VerifyingKey, |
There was a problem hiding this comment.
Replace schnorr::VerifyingKey by [u8] or Vec
src/note/asset_base.rs
Outdated
| /// | ||
| /// [assetdigest]: https://zips.z.cash/zip-0227.html#specification-asset-identifier-asset-digest-and-asset-base | ||
| pub fn asset_digest(asset_id: [u8; 65]) -> Blake2bHash { | ||
| pub fn asset_digest(asset_id: [u8; 66]) -> Blake2bHash { |
There was a problem hiding this comment.
asset_id could not have a fixed length because ik has not a fixed length
a8d34b1 to
9ce9c49
Compare
…ssueAuthSig, along with an assert on the length
9ce9c49 to
e84fdcd
Compare
|
Closed in favour of #182 |
This PR makes the updates to the encoding of the issuance validating key and the issuance authorization signature, as done in the specification in zcash/zips#1042, along with the further updates in zcash/zips#1048 and zcash/zips#1053.
The test vectors are updated in QED-it/zcash-test-vectors#31.