Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/domain/orchard_domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub trait OrchardDomainCommon: fmt::Debug + Clone {
/// with ZCASH_ORCHARD_ACTIONS_MEMOS_HASH_PERSONALIZATION
/// * \[(cv, rk, enc_ciphertext\[564..\], out_ciphertext)*\] personalized
/// with ZCASH_ORCHARD_ACTIONS_NONCOMPACT_HASH_PERSONALIZATION
/// as defined in [ZIP-244: Transaction Identifier Non-Malleability][zip244]
/// as defined in [ZIP-244: Transaction Identifier Non-Malleability][zip244]
///
/// [zip244]: https://zips.z.cash/zip-0244
fn update_hash_with_actions<A: Authorization, V: Copy + Into<i64>>(
Expand Down
9 changes: 3 additions & 6 deletions src/issuance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ impl IssueBundle<Signed> {
/// Validates an [`IssueBundle`] by performing the following checks:
///
/// - **IssueBundle Auth signature verification**:
/// - Ensures the signature on the provided `sighash` matches the bundles authorization.
/// - Ensures the signature on the provided `sighash` matches the bundle's authorization.
/// - **Static IssueAction verification**:
/// - Runs checks using the `IssueAction::verify` method.
/// - **Node global state related verification**:
Expand Down Expand Up @@ -1738,11 +1738,8 @@ mod tests {
rng, ik, recipient, ..
} = setup_params();

// Generated using https://onlinetools.com/utf8/generate-random-utf8
let asset_desc_1 = "󅞞 򬪗YV8𱈇m0{둛򙎠[㷊V֤]9Ծ̖l󾓨2닯򗏟iȰ䣄˃Oߺ񗗼🦄"
.to_string()
.as_bytes()
.to_vec();
// UTF heavy test string
let asset_desc_1 = "ΩΣ𐐷कあ한🐍★→".to_string().as_bytes().to_vec();

let asset_desc_hash_1 = compute_asset_desc_hash(&asset_desc_1).unwrap();

Expand Down
24 changes: 15 additions & 9 deletions src/note/asset_base.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use alloc::vec::Vec;
use blake2b_simd::{Hash as Blake2bHash, Params};
use core::cmp::Ordering;
use core::hash::{Hash, Hasher};
Expand Down Expand Up @@ -45,10 +44,10 @@ pub const ZSA_ASSET_DIGEST_PERSONALIZATION: &[u8; 16] = b"ZSA-Asset-Digest";

/// AssetDigest for the ZSA asset
///
/// Defined in [ZIP-226: Transfer and Burn of Zcash Shielded Assets][assetdigest].
/// Defined in [ZIP-227: Issuance of Zcash Shielded Assets][assetdigest].
///
/// [assetdigest]: https://zips.z.cash/zip-0226.html#asset-identifiers
pub fn asset_digest(asset_id: Vec<u8>) -> Blake2bHash {
/// [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 {
Params::new()
.hash_length(64)
.personal(ZSA_ASSET_DIGEST_PERSONALIZATION)
Expand All @@ -58,12 +57,12 @@ pub fn asset_digest(asset_id: Vec<u8>) -> Blake2bHash {
}

impl AssetBase {
/// Deserialize the asset_id from a byte array.
/// Deserialize the AssetBase from a byte array.
pub fn from_bytes(bytes: &[u8; 32]) -> CtOption<Self> {
pallas::Point::from_bytes(bytes).map(AssetBase)
}

/// Serialize the asset_id to its canonical byte representation.
/// Serialize the AssetBase to its canonical byte representation.
pub fn to_bytes(self) -> [u8; 32] {
self.0.to_bytes()
}
Expand All @@ -76,12 +75,19 @@ impl AssetBase {
///
/// # Panics
///
/// Panics if the derived Asset Base is the identity point.
/// Panics if the derived AssetBase is the identity point.
#[allow(non_snake_case)]
pub fn derive(ik: &IssuanceValidatingKey, asset_desc_hash: &[u8; 32]) -> Self {
// EncodeAssetId(ik, asset_desc_hash) = version_byte || ik || asset_desc_hash
let version_byte = [0x00];
let encode_asset_id = [&version_byte[..], &ik.to_bytes(), asset_desc_hash].concat();

// EncodeAssetId(ik, asset_desc_hash) = version_byte || ik || asset_desc_hash
let encode_asset_id: [u8; 65] = {
let mut array = [0u8; 65];
array[..1].copy_from_slice(&version_byte);
array[1..33].copy_from_slice(&ik.to_bytes());
array[33..].copy_from_slice(asset_desc_hash);
array
};

let asset_digest = asset_digest(encode_asset_id);

Expand Down
4 changes: 2 additions & 2 deletions src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//! - [`ValueSum`], the sum of note values within an Orchard [`Action`] or [`Bundle`].
//! It is a signed 64-bit integer (with range [`VALUE_SUM_RANGE`]).
//! - `valueBalanceOrchard`, which is a signed 63-bit integer. This is represented
//! by a user-defined type parameter on [`Bundle`], returned by
//! [`Bundle::value_balance`] and [`Builder::value_balance`].
//! by a user-defined type parameter on [`Bundle`], returned by
//! [`Bundle::value_balance`] and [`Builder::value_balance`].
//!
//! If your specific instantiation of the Orchard protocol requires a smaller bound on
//! valid note values (for example, Zcash's `MAX_MONEY` fits into a 51-bit integer), you
Expand Down
Loading