Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing the type of the asset description from String to Vec<u8> #113

Open
wants to merge 12 commits into
base: zsa1
Choose a base branch
from
Open
24 changes: 12 additions & 12 deletions src/bundle/burn_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ mod tests {
///
/// A tuple `(AssetBase, Amount)` representing the burn list item.
///
pub fn get_burn_tuple(asset_desc: &str, value: i64) -> (AssetBase, i64) {
pub fn get_burn_tuple(asset_desc: &Vec<u8>, value: i64) -> (AssetBase, i64) {
use crate::keys::{IssuanceAuthorizingKey, IssuanceValidatingKey};

let isk = IssuanceAuthorizingKey::from_bytes([1u8; 32]).unwrap();
Expand All @@ -94,9 +94,9 @@ mod tests {
#[test]
fn validate_bundle_burn_success() {
let bundle_burn = vec![
get_burn_tuple("Asset 1", 10),
get_burn_tuple("Asset 2", 20),
get_burn_tuple("Asset 3", 10),
get_burn_tuple(&b"Asset 1".to_vec(), 10),
get_burn_tuple(&b"Asset 2".to_vec(), 20),
get_burn_tuple(&b"Asset 3".to_vec(), 10),
];

let result = validate_bundle_burn(&bundle_burn);
Expand All @@ -107,9 +107,9 @@ mod tests {
#[test]
fn validate_bundle_burn_duplicate_asset() {
let bundle_burn = vec![
get_burn_tuple("Asset 1", 10),
get_burn_tuple("Asset 1", 20),
get_burn_tuple("Asset 3", 10),
get_burn_tuple(&b"Asset 1".to_vec(), 10),
get_burn_tuple(&b"Asset 1".to_vec(), 20),
get_burn_tuple(&b"Asset 3".to_vec(), 10),
];

let result = validate_bundle_burn(&bundle_burn);
Expand All @@ -120,9 +120,9 @@ mod tests {
#[test]
fn validate_bundle_burn_native_asset() {
let bundle_burn = vec![
get_burn_tuple("Asset 1", 10),
get_burn_tuple(&b"Asset 1".to_vec(), 10),
(AssetBase::native(), 20),
get_burn_tuple("Asset 3", 10),
get_burn_tuple(&b"Asset 3".to_vec(), 10),
];

let result = validate_bundle_burn(&bundle_burn);
Expand All @@ -133,9 +133,9 @@ mod tests {
#[test]
fn validate_bundle_burn_zero_value() {
let bundle_burn = vec![
get_burn_tuple("Asset 1", 10),
get_burn_tuple("Asset 2", 0),
get_burn_tuple("Asset 3", 10),
get_burn_tuple(&b"Asset 1".to_vec(), 10),
get_burn_tuple(&b"Asset 2".to_vec(), 0),
get_burn_tuple(&b"Asset 3".to_vec(), 10),
];

let result = validate_bundle_burn(&bundle_burn);
Expand Down
4 changes: 2 additions & 2 deletions src/bundle/commitments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ pub(crate) fn hash_issue_bundle_txid_data<A: IssueAuth>(bundle: &IssueBundle<A>)
let mut h = hasher(ZCASH_ORCHARD_ZSA_ISSUE_PERSONALIZATION);
let mut ia = hasher(ZCASH_ORCHARD_ZSA_ISSUE_ACTION_PERSONALIZATION);

for action in bundle.actions().iter() {
for action in bundle.actions() {
let mut ind = hasher(ZCASH_ORCHARD_ZSA_ISSUE_NOTE_PERSONALIZATION);
for note in action.notes().iter() {
ind.update(&note.recipient().to_raw_address_bytes());
Expand All @@ -172,7 +172,7 @@ pub(crate) fn hash_issue_bundle_txid_data<A: IssueAuth>(bundle: &IssueBundle<A>)
ind.update(note.rseed().as_bytes());
}
ia.update(ind.finalize().as_bytes());
ia.update(action.asset_desc().as_bytes());
ia.update(action.asset_desc());
ia.update(&[u8::from(action.is_finalized())]);
}
h.update(ia.finalize().as_bytes());
Expand Down
Loading
Loading