diff --git a/masp_primitives/src/convert.rs b/masp_primitives/src/convert.rs index d9fd728e..b5aa63ac 100644 --- a/masp_primitives/src/convert.rs +++ b/masp_primitives/src/convert.rs @@ -3,7 +3,7 @@ use crate::{ pedersen_hash::{pedersen_hash, Personalization}, Node, ValueCommitment, }, - transaction::components::amount::{I32Sum, ValueSum}, + transaction::components::amount::{I128Sum, ValueSum}, }; use borsh::{BorshDeserialize, BorshSerialize}; use group::{Curve, GroupEncoding}; @@ -16,7 +16,7 @@ use std::{ #[derive(Clone, Debug, PartialEq, Eq)] pub struct AllowedConversion { /// The asset type that the note represents - assets: I32Sum, + assets: I128Sum, /// Memorize generator because it's expensive to recompute generator: jubjub::ExtendedPoint, } @@ -71,15 +71,15 @@ impl AllowedConversion { } } -impl From for I32Sum { - fn from(allowed_conversion: AllowedConversion) -> I32Sum { +impl From for I128Sum { + fn from(allowed_conversion: AllowedConversion) -> I128Sum { allowed_conversion.assets } } -impl From for AllowedConversion { +impl From for AllowedConversion { /// Produces an asset generator without cofactor cleared - fn from(assets: I32Sum) -> Self { + fn from(assets: I128Sum) -> Self { let mut asset_generator = jubjub::ExtendedPoint::identity(); for (asset, value) in assets.components() { // Compute the absolute value (failing if -i64::MAX is @@ -123,7 +123,7 @@ impl BorshDeserialize for AllowedConversion { /// computation of checking whether the asset generator corresponds to the /// deserialized amount. fn deserialize_reader(reader: &mut R) -> io::Result { - let assets = I32Sum::read(reader)?; + let assets = I128Sum::read(reader)?; let gen_bytes = <::Repr as BorshDeserialize>::deserialize_reader(reader)?; let generator = Option::from(jubjub::ExtendedPoint::from_bytes(&gen_bytes)) @@ -199,12 +199,12 @@ mod tests { #[test] fn test_homomorphism() { // Left operand - let a = ValueSum::from_pair(zec(), 5i32).unwrap() - + ValueSum::from_pair(btc(), 6i32).unwrap() - + ValueSum::from_pair(xan(), 7i32).unwrap(); + let a = ValueSum::from_pair(zec(), 5i128).unwrap() + + ValueSum::from_pair(btc(), 6i128).unwrap() + + ValueSum::from_pair(xan(), 7i128).unwrap(); // Right operand - let b = - ValueSum::from_pair(zec(), 2i32).unwrap() + ValueSum::from_pair(xan(), 10i32).unwrap(); + let b = ValueSum::from_pair(zec(), 2i128).unwrap() + + ValueSum::from_pair(xan(), 10i128).unwrap(); // Test homomorphism assert_eq!( AllowedConversion::from(a.clone() + b.clone()), @@ -214,9 +214,9 @@ mod tests { #[test] fn test_serialization() { // Make conversion - let a: AllowedConversion = (ValueSum::from_pair(zec(), 5i32).unwrap() - + ValueSum::from_pair(btc(), 6i32).unwrap() - + ValueSum::from_pair(xan(), 7i32).unwrap()) + let a: AllowedConversion = (ValueSum::from_pair(zec(), 5i128).unwrap() + + ValueSum::from_pair(btc(), 6i128).unwrap() + + ValueSum::from_pair(xan(), 7i128).unwrap()) .into(); // Serialize conversion let mut data = Vec::new(); diff --git a/masp_primitives/src/transaction/components/sapling/builder.rs b/masp_primitives/src/transaction/components/sapling/builder.rs index c68449f9..b902e603 100644 --- a/masp_primitives/src/transaction/components/sapling/builder.rs +++ b/masp_primitives/src/transaction/components/sapling/builder.rs @@ -25,7 +25,7 @@ use crate::{ transaction::{ builder::Progress, components::{ - amount::{I128Sum, I32Sum, ValueSum, MAX_MONEY}, + amount::{I128Sum, ValueSum, MAX_MONEY}, sapling::{ fees, Authorization, Authorized, Bundle, ConvertDescription, GrothProofBytes, OutputDescription, SpendDescription, @@ -438,7 +438,7 @@ impl SaplingBuilder

{ self.convert_anchor = Some(merkle_path.root(node).into()) } - let allowed_amt: I32Sum = allowed.clone().into(); + let allowed_amt: I128Sum = allowed.clone().into(); self.value_balance += I128Sum::from_sum(allowed_amt) * (value as i128); self.converts.push(ConvertDescriptionInfo { diff --git a/masp_proofs/benches/convert.rs b/masp_proofs/benches/convert.rs index 60fbbc74..0ac849fe 100644 --- a/masp_proofs/benches/convert.rs +++ b/masp_proofs/benches/convert.rs @@ -34,9 +34,9 @@ fn criterion_benchmark(c: &mut Criterion) { let output_asset = AssetType::new(format!("asset {}", i + 1).as_bytes()).unwrap(); let mint_asset = AssetType::new(b"reward").unwrap(); - let spend_value = -(i as i32 + 1); - let output_value = i as i32 + 1; - let mint_value = i as i32 + 1; + let spend_value = -(i as i128 + 1); + let output_value = i as i128 + 1; + let mint_value = i as i128 + 1; let allowed_conversion: AllowedConversion = (ValueSum::from_pair(spend_asset, spend_value) .unwrap() diff --git a/masp_proofs/src/circuit/convert.rs b/masp_proofs/src/circuit/convert.rs index c8bcb300..7fbcc88b 100644 --- a/masp_proofs/src/circuit/convert.rs +++ b/masp_proofs/src/circuit/convert.rs @@ -150,9 +150,9 @@ fn test_convert_circuit_with_bls12_381() { let output_asset = AssetType::new(format!("asset {}", i + 1).as_bytes()).unwrap(); let mint_asset = AssetType::new(b"reward").unwrap(); - let spend_value = -(i as i32 + 1); - let output_value = i as i32 + 1; - let mint_value = i as i32 + 1; + let spend_value = -(i as i128 + 1); + let output_value = i as i128 + 1; + let mint_value = i as i128 + 1; let allowed_conversion: AllowedConversion = (ValueSum::from_pair(spend_asset, spend_value) .unwrap()