diff --git a/.changelog/unreleased/improvements/3296-test-vectors-with-randomness2.md b/.changelog/unreleased/improvements/3296-test-vectors-with-randomness2.md new file mode 100644 index 00000000000..48ae627d245 --- /dev/null +++ b/.changelog/unreleased/improvements/3296-test-vectors-with-randomness2.md @@ -0,0 +1,2 @@ +- Include the used MASP randomness parameters in the test vectors. + ([\#3296](https://github.com/anoma/namada/pull/3296)) \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index c3b4a86b51e..81ff7038532 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4141,7 +4141,7 @@ dependencies = [ [[package]] name = "masp_note_encryption" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=3aacc707c5948e7423589ac617305448bead9842#3aacc707c5948e7423589ac617305448bead9842" +source = "git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82#4ede1c42d76d6348af8224bc8bfac4404321fe82" dependencies = [ "borsh 1.2.1", "chacha20", @@ -4154,7 +4154,7 @@ dependencies = [ [[package]] name = "masp_primitives" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=3aacc707c5948e7423589ac617305448bead9842#3aacc707c5948e7423589ac617305448bead9842" +source = "git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82#4ede1c42d76d6348af8224bc8bfac4404321fe82" dependencies = [ "aes", "bip0039", @@ -4186,7 +4186,7 @@ dependencies = [ [[package]] name = "masp_proofs" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=3aacc707c5948e7423589ac617305448bead9842#3aacc707c5948e7423589ac617305448bead9842" +source = "git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82#4ede1c42d76d6348af8224bc8bfac4404321fe82" dependencies = [ "bellman", "blake2b_simd", @@ -4670,6 +4670,7 @@ version = "0.37.0" dependencies = [ "borsh 1.2.1", "data-encoding", + "masp_primitives", "masp_proofs", "namada_apps_lib", "namada_macros", diff --git a/Cargo.toml b/Cargo.toml index 0d1f58a5774..4ecc4c7083e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -125,8 +125,8 @@ libc = "0.2.97" libloading = "0.7.2" linkme = "0.3.24" # branch = "main" -masp_primitives = { git = "https://github.com/anoma/masp", rev = "3aacc707c5948e7423589ac617305448bead9842" } -masp_proofs = { git = "https://github.com/anoma/masp", rev = "3aacc707c5948e7423589ac617305448bead9842", default-features = false, features = ["local-prover"] } +masp_primitives = { git = "https://github.com/anoma/masp", rev = "4ede1c42d76d6348af8224bc8bfac4404321fe82" } +masp_proofs = { git = "https://github.com/anoma/masp", rev = "4ede1c42d76d6348af8224bc8bfac4404321fe82", default-features = false, features = ["local-prover"] } num256 = "0.3.5" num_cpus = "1.13.0" num-derive = "0.4" diff --git a/crates/sdk/src/lib.rs b/crates/sdk/src/lib.rs index f1d6d672ee9..2d6c060c4d8 100644 --- a/crates/sdk/src/lib.rs +++ b/crates/sdk/src/lib.rs @@ -801,6 +801,7 @@ pub mod testing { use borsh_ext::BorshSerializeExt; use governance::ProposalType; use ibc::primitives::proto::Any; + use masp_primitives::transaction::components::sapling::builder::StoredBuildParams; use masp_primitives::transaction::TransparentAddress; use namada_account::{InitAccount, UpdateAccount}; use namada_core::address::testing::{ @@ -870,6 +871,7 @@ pub mod testing { VoteProposal(VoteProposalData), Withdraw(Withdraw), Transfer(Transfer), + MaspTransfer(Transfer, (StoredBuildParams, String)), Bond(Bond), Redelegation(Redelegation), UpdateStewardCommission(UpdateStewardCommission), @@ -1067,7 +1069,7 @@ pub mod testing { mut header in arb_header(), wrapper in arb_wrapper_tx(), code_hash in arb_hash(), - (masp_tx_type, (shielded_transfer, asset_types)) in prop_oneof![ + (masp_tx_type, (shielded_transfer, asset_types, build_params)) in prop_oneof![ (Just(MaspTxType::Shielded), arb_shielded_transfer(0..MAX_ASSETS)), (Just(MaspTxType::Shielding), arb_shielding_transfer(encode_address(&transfer.source), 1)), (Just(MaspTxType::Deshielding), arb_deshielding_transfer(encode_address(&transfer.target), 1)), @@ -1116,7 +1118,9 @@ pub mod testing { // Link the Builder to the Transaction by hash code target: masp_tx_hash, }); - (tx, TxData::Transfer(transfer)) + let build_param_bytes = + data_encoding::HEXLOWER.encode(&build_params.serialize_to_vec()); + (tx, TxData::MaspTransfer(transfer, (build_params, build_param_bytes))) } } diff --git a/crates/sdk/src/masp.rs b/crates/sdk/src/masp.rs index 3fe9c0f2228..1ca8a26cd27 100644 --- a/crates/sdk/src/masp.rs +++ b/crates/sdk/src/masp.rs @@ -2167,6 +2167,7 @@ pub mod testing { use masp_primitives::sapling::prover::TxProver; use masp_primitives::sapling::redjubjub::Signature; use masp_primitives::sapling::{ProofGenerationKey, Rseed}; + use masp_primitives::transaction::components::sapling::builder::StoredBuildParams; use masp_primitives::transaction::components::GROTH_PROOF_SIZE; use masp_proofs::bellman::groth16::Proof; use proptest::prelude::*; @@ -2938,19 +2939,20 @@ pub mod testing { prover_rng in arb_rng().prop_map(TestCsprng), mut rng in arb_rng().prop_map(TestCsprng), bparams_rng in arb_rng().prop_map(TestCsprng), - ) -> (ShieldedTransfer, HashMap) { + ) -> (ShieldedTransfer, HashMap, StoredBuildParams) { + let mut rng_build_params = RngBuildParams::new(bparams_rng); let (masp_tx, metadata) = builder.clone().build( &MockTxProver(Mutex::new(prover_rng)), &FeeRule::non_standard(U64Sum::zero()), &mut rng, - &mut RngBuildParams::new(bparams_rng), + &mut rng_build_params, ).unwrap(); (ShieldedTransfer { builder: builder.map_builder(WalletMap), metadata, masp_tx, epoch, - }, asset_types) + }, asset_types, rng_build_params.to_stored().unwrap()) } } @@ -2968,19 +2970,20 @@ pub mod testing { prover_rng in arb_rng().prop_map(TestCsprng), mut rng in arb_rng().prop_map(TestCsprng), bparams_rng in arb_rng().prop_map(TestCsprng), - ) -> (ShieldedTransfer, HashMap) { + ) -> (ShieldedTransfer, HashMap, StoredBuildParams) { + let mut rng_build_params = RngBuildParams::new(bparams_rng); let (masp_tx, metadata) = builder.clone().build( &MockTxProver(Mutex::new(prover_rng)), &FeeRule::non_standard(U64Sum::zero()), &mut rng, - &mut RngBuildParams::new(bparams_rng), + &mut rng_build_params, ).unwrap(); (ShieldedTransfer { builder: builder.map_builder(WalletMap), metadata, masp_tx, epoch, - }, asset_types) + }, asset_types, rng_build_params.to_stored().unwrap()) } } @@ -2998,19 +3001,20 @@ pub mod testing { prover_rng in arb_rng().prop_map(TestCsprng), mut rng in arb_rng().prop_map(TestCsprng), bparams_rng in arb_rng().prop_map(TestCsprng), - ) -> (ShieldedTransfer, HashMap) { + ) -> (ShieldedTransfer, HashMap, StoredBuildParams) { + let mut rng_build_params = RngBuildParams::new(bparams_rng); let (masp_tx, metadata) = builder.clone().build( &MockTxProver(Mutex::new(prover_rng)), &FeeRule::non_standard(U64Sum::zero()), &mut rng, - &mut RngBuildParams::new(bparams_rng), + &mut rng_build_params, ).unwrap(); (ShieldedTransfer { builder: builder.map_builder(WalletMap), metadata, masp_tx, epoch, - }, asset_types) + }, asset_types, rng_build_params.to_stored().unwrap()) } } } diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 031e04248ce..1720015a94c 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -28,6 +28,7 @@ path = "make-db-migration.rs" namada-eth-bridge = ["namada_sdk/namada-eth-bridge"] [dev-dependencies] +masp_primitives = { workspace = true, features = ["transparent-inputs"] } masp_proofs = { workspace = true, default-features = false, features = ["local-prover", "download-params"] } namada_apps_lib = {path = "../crates/apps_lib", features = ["migrations"]} namada_macros = {path = "../crates/macros"} diff --git a/examples/tx_schema.rs b/examples/tx_schema.rs index e3d678eefed..1fcf24e1625 100644 --- a/examples/tx_schema.rs +++ b/examples/tx_schema.rs @@ -1,6 +1,7 @@ use std::collections::BTreeMap; use std::error::Error; +use masp_primitives::transaction::components::sapling::builder::StoredBuildParams; use namada_sdk::borsh::BorshSchema; use namada_sdk::tx::Tx; @@ -12,6 +13,7 @@ fn main() -> Result<(), Box> { } let mut definitions = BTreeMap::new(); Tx::add_definitions_recursively(&mut definitions); + StoredBuildParams::add_definitions_recursively(&mut definitions); std::fs::write(&args[1], format!("{:#?}", definitions)) .expect("unable to save schema"); Ok(()) diff --git a/wasm/Cargo.lock b/wasm/Cargo.lock index 479e40076d2..fc3cfdfce60 100644 --- a/wasm/Cargo.lock +++ b/wasm/Cargo.lock @@ -3362,7 +3362,7 @@ dependencies = [ [[package]] name = "masp_note_encryption" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=3aacc707c5948e7423589ac617305448bead9842#3aacc707c5948e7423589ac617305448bead9842" +source = "git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82#4ede1c42d76d6348af8224bc8bfac4404321fe82" dependencies = [ "borsh 1.4.0", "chacha20", @@ -3375,7 +3375,7 @@ dependencies = [ [[package]] name = "masp_primitives" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=3aacc707c5948e7423589ac617305448bead9842#3aacc707c5948e7423589ac617305448bead9842" +source = "git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82#4ede1c42d76d6348af8224bc8bfac4404321fe82" dependencies = [ "aes", "bip0039", @@ -3407,7 +3407,7 @@ dependencies = [ [[package]] name = "masp_proofs" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=3aacc707c5948e7423589ac617305448bead9842#3aacc707c5948e7423589ac617305448bead9842" +source = "git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82#4ede1c42d76d6348af8224bc8bfac4404321fe82" dependencies = [ "bellman", "blake2b_simd", diff --git a/wasm_for_tests/Cargo.lock b/wasm_for_tests/Cargo.lock index 85a3a3db7fb..c37b4ab2e04 100644 --- a/wasm_for_tests/Cargo.lock +++ b/wasm_for_tests/Cargo.lock @@ -3342,7 +3342,7 @@ dependencies = [ [[package]] name = "masp_note_encryption" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=3aacc707c5948e7423589ac617305448bead9842#3aacc707c5948e7423589ac617305448bead9842" +source = "git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82#4ede1c42d76d6348af8224bc8bfac4404321fe82" dependencies = [ "borsh 1.2.1", "chacha20", @@ -3355,7 +3355,7 @@ dependencies = [ [[package]] name = "masp_primitives" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=3aacc707c5948e7423589ac617305448bead9842#3aacc707c5948e7423589ac617305448bead9842" +source = "git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82#4ede1c42d76d6348af8224bc8bfac4404321fe82" dependencies = [ "aes", "bip0039", @@ -3387,7 +3387,7 @@ dependencies = [ [[package]] name = "masp_proofs" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=3aacc707c5948e7423589ac617305448bead9842#3aacc707c5948e7423589ac617305448bead9842" +source = "git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82#4ede1c42d76d6348af8224bc8bfac4404321fe82" dependencies = [ "bellman", "blake2b_simd",