diff --git a/apps/src/lib/node/ledger/shell/finalize_block.rs b/apps/src/lib/node/ledger/shell/finalize_block.rs index 57ed9269e0d..2266343be12 100644 --- a/apps/src/lib/node/ledger/shell/finalize_block.rs +++ b/apps/src/lib/node/ledger/shell/finalize_block.rs @@ -1099,7 +1099,7 @@ mod test_finalize_block { validator_consensus_key_handle, validator_rewards_products_handle, validator_slashes_handle, validator_state_handle, write_pos_params, }; - use namada::proto::{Code, Data, Section, Signature}; + use namada::proto::{Code, Data, Signature, Section}; use namada::types::dec::POS_DECIMAL_PRECISION; use namada::types::ethereum_events::{EthAddress, Uint as ethUint}; use namada::types::hash::Hash; @@ -1156,7 +1156,8 @@ mod test_finalize_block { )); wrapper_tx.add_section(Section::Signature(Signature::new( wrapper_tx.sechashes(), - keypair, + [(0, keypair.clone())].into_iter().collect(), + None ))); let tx = wrapper_tx.to_bytes(); ( @@ -2489,7 +2490,8 @@ mod test_finalize_block { )); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); let wrapper_hash_key = replay_protection::get_replay_protection_key( @@ -2562,7 +2564,8 @@ mod test_finalize_block { )); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &keypair, + [(0, keypair.clone())].into_iter().collect(), + None, ))); let processed_tx = ProcessedTx { @@ -2646,7 +2649,8 @@ mod test_finalize_block { )); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &crate::wallet::defaults::albert_keypair(), + [(0, crate::wallet::defaults::albert_keypair())].into_iter().collect(), + None, ))); let fee_amount = wrapper.header().wrapper().unwrap().get_tx_fee().unwrap(); diff --git a/apps/src/lib/node/ledger/shell/mod.rs b/apps/src/lib/node/ledger/shell/mod.rs index 46a985b8fcf..933d1a9bfca 100644 --- a/apps/src/lib/node/ledger/shell/mod.rs +++ b/apps/src/lib/node/ledger/shell/mod.rs @@ -2159,7 +2159,7 @@ mod test_utils { #[cfg(all(test, not(feature = "abcipp")))] mod abciplus_mempool_tests { use namada::proto::{ - Data, Section, SignableEthMessage, Signature, Signed, Tx, + Data, Signature, Section, SignableEthMessage, Signed, Tx, }; use namada::types::ethereum_events::EthereumEvent; use namada::types::key::RefTo; @@ -2299,7 +2299,8 @@ mod abciplus_mempool_tests { tx.set_data(Data::new(ext.try_to_vec().expect("Test falied"))); tx.add_section(Section::Signature(Signature::new( tx.sechashes(), - &protocol_key, + [(0, protocol_key)].into_iter().collect(), + None, ))); tx } @@ -2312,7 +2313,7 @@ mod abciplus_mempool_tests { #[cfg(test)] mod test_mempool_validate { use namada::proof_of_stake::Epoch; - use namada::proto::{Code, Data, Section, Signature, Tx}; + use namada::proto::{Code, Data, Signature, Section, Tx}; use namada::types::transaction::{Fee, WrapperTx}; use super::*; @@ -2384,7 +2385,8 @@ mod test_mempool_validate { .set_data(Data::new("transaction data".as_bytes().to_owned())); invalid_wrapper.add_section(Section::Signature(Signature::new( invalid_wrapper.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); // we mount a malleability attack to try and remove the fee @@ -2452,7 +2454,8 @@ mod test_mempool_validate { wrapper.set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); // Write wrapper hash to storage @@ -2611,7 +2614,8 @@ mod test_mempool_validate { wrapper.set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); let result = shell.mempool_validate( @@ -2645,7 +2649,8 @@ mod test_mempool_validate { wrapper.set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); let result = shell.mempool_validate( @@ -2679,7 +2684,8 @@ mod test_mempool_validate { wrapper.set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &crate::wallet::defaults::albert_keypair(), + [(0, crate::wallet::defaults::albert_keypair())].into_iter().collect(), + None, ))); let result = shell.mempool_validate( @@ -2713,7 +2719,8 @@ mod test_mempool_validate { wrapper.set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &crate::wallet::defaults::albert_keypair(), + [(0, crate::wallet::defaults::albert_keypair())].into_iter().collect(), + None, ))); let result = shell.mempool_validate( @@ -2746,7 +2753,8 @@ mod test_mempool_validate { wrapper.set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &crate::wallet::defaults::albert_keypair(), + [(0, crate::wallet::defaults::albert_keypair())].into_iter().collect(), + None, ))); let result = shell.mempool_validate( @@ -2779,7 +2787,8 @@ mod test_mempool_validate { wrapper.set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &crate::wallet::defaults::albert_keypair(), + [(0, crate::wallet::defaults::albert_keypair())].into_iter().collect(), + None, ))); let result = shell.mempool_validate( diff --git a/apps/src/lib/node/ledger/shell/prepare_proposal.rs b/apps/src/lib/node/ledger/shell/prepare_proposal.rs index e8633940b9a..612d19b6fbf 100644 --- a/apps/src/lib/node/ledger/shell/prepare_proposal.rs +++ b/apps/src/lib/node/ledger/shell/prepare_proposal.rs @@ -522,7 +522,7 @@ mod test_prepare_proposal { }; #[cfg(feature = "abcipp")] use namada::proto::SignableEthMessage; - use namada::proto::{Code, Data, Header, Section, Signature, Signed}; + use namada::proto::{Code, Data, Header, Signature, Section, Signed}; use namada::types::address::{self, Address}; use namada::types::ethereum_events::EthereumEvent; #[cfg(feature = "abcipp")] @@ -1135,7 +1135,8 @@ mod test_prepare_proposal { )); tx.add_section(Section::Signature(Signature::new( tx.sechashes(), - &keypair, + [(0, keypair.clone())].into_iter().collect(), + None, ))); let gas = Gas::from( @@ -1208,7 +1209,8 @@ mod test_prepare_proposal { wrapper.set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); // Write wrapper hash to storage @@ -1262,7 +1264,8 @@ mod test_prepare_proposal { wrapper.set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); let req = RequestPrepareProposal { @@ -1304,7 +1307,8 @@ mod test_prepare_proposal { wrapper.set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); let inner_unsigned_hash = wrapper.clone().update_header(TxType::Raw).header_hash(); @@ -1362,7 +1366,8 @@ mod test_prepare_proposal { let mut new_wrapper = wrapper.clone(); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); new_wrapper.update_header(TxType::Wrapper(Box::new(WrapperTx::new( @@ -1379,7 +1384,8 @@ mod test_prepare_proposal { )))); new_wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &keypair_2, + [(0, keypair_2)].into_iter().collect(), + None, ))); let req = RequestPrepareProposal { @@ -1421,7 +1427,8 @@ mod test_prepare_proposal { .set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper_tx.add_section(Section::Signature(Signature::new( wrapper_tx.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); let time = DateTimeUtc::now(); @@ -1471,7 +1478,8 @@ mod test_prepare_proposal { .set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper_tx.add_section(Section::Signature(Signature::new( wrapper_tx.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); let req = RequestPrepareProposal { @@ -1512,7 +1520,8 @@ mod test_prepare_proposal { .set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper_tx.add_section(Section::Signature(Signature::new( wrapper_tx.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); let req = RequestPrepareProposal { @@ -1552,7 +1561,8 @@ mod test_prepare_proposal { .set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper_tx.add_section(Section::Signature(Signature::new( wrapper_tx.sechashes(), - &crate::wallet::defaults::albert_keypair(), + [(0, crate::wallet::defaults::albert_keypair())].into_iter().collect(), + None, ))); let req = RequestPrepareProposal { @@ -1591,7 +1601,8 @@ mod test_prepare_proposal { .set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper_tx.add_section(Section::Signature(Signature::new( wrapper_tx.sechashes(), - &crate::wallet::defaults::albert_keypair(), + [(0, crate::wallet::defaults::albert_keypair())].into_iter().collect(), + None, ))); let req = RequestPrepareProposal { @@ -1629,7 +1640,8 @@ mod test_prepare_proposal { .set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper_tx.add_section(Section::Signature(Signature::new( wrapper_tx.sechashes(), - &crate::wallet::defaults::albert_keypair(), + [(0, crate::wallet::defaults::albert_keypair())].into_iter().collect(), + None, ))); let req = RequestPrepareProposal { @@ -1667,7 +1679,8 @@ mod test_prepare_proposal { .set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper_tx.add_section(Section::Signature(Signature::new( wrapper_tx.sechashes(), - &crate::wallet::defaults::albert_keypair(), + [(0, crate::wallet::defaults::albert_keypair())].into_iter().collect(), + None, ))); let req = RequestPrepareProposal { diff --git a/apps/src/lib/node/ledger/shell/process_proposal.rs b/apps/src/lib/node/ledger/shell/process_proposal.rs index dca2d4fe4ed..e9d93b8ce0b 100644 --- a/apps/src/lib/node/ledger/shell/process_proposal.rs +++ b/apps/src/lib/node/ledger/shell/process_proposal.rs @@ -1002,7 +1002,7 @@ mod test_process_proposal { use assert_matches::assert_matches; use namada::ledger::storage_api::StorageWrite; use namada::proto::{ - Code, Data, Section, SignableEthMessage, Signature, Signed, + Code, Data, Signature, Section, SignableEthMessage, Signed, }; use namada::types::ethereum_events::EthereumEvent; use namada::types::hash::Hash; @@ -1660,7 +1660,8 @@ mod test_process_proposal { outer_tx.set_data(Data::new("transaction data".as_bytes().to_owned())); outer_tx.add_section(Section::Signature(Signature::new( outer_tx.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); let mut new_tx = outer_tx.clone(); if let TxType::Wrapper(wrapper) = &mut new_tx.header.tx_type { @@ -1733,7 +1734,8 @@ mod test_process_proposal { outer_tx.set_data(Data::new("transaction data".as_bytes().to_owned())); outer_tx.add_section(Section::Signature(Signature::new( outer_tx.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); let response = { @@ -1799,7 +1801,8 @@ mod test_process_proposal { outer_tx.set_data(Data::new("transaction data".as_bytes().to_owned())); outer_tx.add_section(Section::Signature(Signature::new( outer_tx.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); let response = { @@ -2164,7 +2167,8 @@ mod test_process_proposal { wrapper.set_code(Code::new("wasm_code".as_bytes().to_owned())); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); // Write wrapper hash to storage @@ -2241,7 +2245,8 @@ mod test_process_proposal { wrapper.set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); // Run validation @@ -2300,7 +2305,8 @@ mod test_process_proposal { wrapper.set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); let inner_unsigned_hash = wrapper.clone().update_header(TxType::Raw).header_hash(); @@ -2365,7 +2371,8 @@ mod test_process_proposal { let mut new_wrapper = wrapper.clone(); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); let inner_unsigned_hash = wrapper.clone().update_header(TxType::Raw).header_hash(); @@ -2384,7 +2391,8 @@ mod test_process_proposal { )))); new_wrapper.add_section(Section::Signature(Signature::new( new_wrapper.sechashes(), - &keypair_2, + [(0, keypair_2)].into_iter().collect(), + None, ))); // Run validation @@ -2437,7 +2445,8 @@ mod test_process_proposal { wrapper.set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); let protocol_key = shell.mode.get_protocol_key().expect("Test failed"); @@ -2506,7 +2515,8 @@ mod test_process_proposal { })); decrypted.add_section(Section::Signature(Signature::new( decrypted.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); let gas_limit = Gas::from(wrapper.header.wrapper().unwrap().gas_limit) .checked_sub(Gas::from(wrapper.to_bytes().len() as u64)) @@ -2567,7 +2577,8 @@ mod test_process_proposal { wrapper.set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); // Run validation @@ -2617,7 +2628,8 @@ mod test_process_proposal { })); decrypted.add_section(Section::Signature(Signature::new( decrypted.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); let gas_limit = Gas::from(wrapper.header.wrapper().unwrap().gas_limit) .checked_sub(Gas::from(wrapper.to_bytes().len() as u64)) @@ -2674,7 +2686,8 @@ mod test_process_proposal { wrapper.set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); // Run validation @@ -2717,7 +2730,8 @@ mod test_process_proposal { wrapper.set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); // Run validation @@ -2759,7 +2773,8 @@ mod test_process_proposal { wrapper.set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &crate::wallet::defaults::albert_keypair(), + [(0, crate::wallet::defaults::albert_keypair())].into_iter().collect(), + None, ))); // Run validation @@ -2801,7 +2816,8 @@ mod test_process_proposal { wrapper.set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &crate::wallet::defaults::albert_keypair(), + [(0, crate::wallet::defaults::albert_keypair())].into_iter().collect(), + None, ))); // Run validation @@ -2843,7 +2859,8 @@ mod test_process_proposal { wrapper.set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &crate::wallet::defaults::albert_keypair(), + [(0, crate::wallet::defaults::albert_keypair())].into_iter().collect(), + None, ))); // Run validation @@ -2885,7 +2902,8 @@ mod test_process_proposal { wrapper.set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &crate::wallet::defaults::albert_keypair(), + [(0, crate::wallet::defaults::albert_keypair())].into_iter().collect(), + None, ))); // Run validation @@ -2930,7 +2948,8 @@ mod test_process_proposal { wrapper.set_data(Data::new("transaction data".as_bytes().to_owned())); wrapper.add_section(Section::Signature(Signature::new( wrapper.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); let wrapper = wrapper.to_bytes(); for height in [1u64, 2] { diff --git a/benches/host_env.rs b/benches/host_env.rs index a55b97a2470..3bc1a6a38e3 100644 --- a/benches/host_env.rs +++ b/benches/host_env.rs @@ -3,7 +3,7 @@ use criterion::{criterion_group, criterion_main, Criterion}; use namada::core::types::account::AccountPublicKeysMap; use namada::core::types::address; use namada::core::types::token::{Amount, Transfer}; -use namada::proto::{Data, MultiSignature, Section}; +use namada::proto::{Data, Signature, Section}; use namada_apps::wallet::defaults; use std::collections::HashSet; @@ -25,7 +25,7 @@ fn tx_section_signature_validation(c: &mut Criterion) { defaults::albert_keypair().to_public() ]); - let multisig = MultiSignature::new( + let multisig = Signature::new( vec![section_hash], pkim.index_secret_keys(vec![defaults::albert_keypair()]), None, diff --git a/benches/lib.rs b/benches/lib.rs index 11042c84b3a..c04e1f3b585 100644 --- a/benches/lib.rs +++ b/benches/lib.rs @@ -73,7 +73,7 @@ use namada::ledger::queries::{ }; use namada::ledger::wallet::Wallet; use namada::proof_of_stake; -use namada::proto::{Code, Data, Section, Signature, Tx}; +use namada::proto::{Code, Data, Signature, Section, Tx}; use namada::tendermint::Hash; use namada::tendermint_rpc::{self}; use namada::types::address::InternalAddress; @@ -435,7 +435,8 @@ pub fn generate_tx( if let Some(signer) = signer { tx.add_section(Section::Signature(Signature::new( tx.sechashes(), - signer, + [(0, signer.clone())].into_iter().collect(), + None, ))); } @@ -481,7 +482,11 @@ pub fn generate_foreign_key_tx(signer: &SecretKey) -> Tx { .try_to_vec() .unwrap(), )); - tx.add_section(Section::Signature(Signature::new(tx.sechashes(), signer))); + tx.add_section(Section::Signature(Signature::new( + tx.sechashes(), + [(0, signer.clone())].into_iter().collect(), + None, + ))); tx } diff --git a/benches/process_wrapper.rs b/benches/process_wrapper.rs index 72b26e0cb18..55bbf02777b 100644 --- a/benches/process_wrapper.rs +++ b/benches/process_wrapper.rs @@ -49,7 +49,8 @@ fn process_tx(c: &mut Criterion) { ))); tx.add_section(namada::proto::Section::Signature(Signature::new( tx.sechashes(), - &defaults::albert_keypair(), + [(0, defaults::albert_keypair())].into_iter().collect(), + None, ))); let wrapper = tx.to_bytes(); diff --git a/core/src/proto/mod.rs b/core/src/proto/mod.rs index e8411a41d2d..ad00d3e5808 100644 --- a/core/src/proto/mod.rs +++ b/core/src/proto/mod.rs @@ -4,9 +4,8 @@ pub mod generated; mod types; pub use types::{ - Code, Commitment, Data, Dkg, Error, Header, MaspBuilder, MultiSignature, - Section, Signable, SignableEthMessage, Signature, SignatureIndex, Signed, - Tx, TxError, + Code, Commitment, Data, Dkg, Error, Header, MaspBuilder, Signature, + Section, Signable, SignableEthMessage, SignatureIndex, Signed, Tx, TxError, }; #[cfg(test)] diff --git a/core/src/proto/types.rs b/core/src/proto/types.rs index 0c59fd1e0a4..9130164ee63 100644 --- a/core/src/proto/types.rs +++ b/core/src/proto/types.rs @@ -468,7 +468,7 @@ pub enum Signer { Serialize, Deserialize, )] -pub struct MultiSignature { +pub struct Signature { /// The hash of the section being signed pub targets: Vec, /// The public keys against which the signatures should be verified @@ -477,7 +477,7 @@ pub struct MultiSignature { pub signatures: BTreeMap, } -impl MultiSignature { +impl Signature { /// Sign the given section hash with the given key and return a section pub fn new( targets: Vec, @@ -553,7 +553,8 @@ impl MultiSignature { &self, verified_pks: &mut HashSet, public_keys_index_map: &AccountPublicKeysMap, - ) -> std::result::Result<(), VerifySigError> { + ) -> std::result::Result { + let mut partial = false; match &self.signer { Signer::Address(_) => { for (idx, sig) in &self.signatures { @@ -564,6 +565,7 @@ impl MultiSignature { sig, )?; verified_pks.insert(pk); + partial = true; } } }, @@ -576,76 +578,12 @@ impl MultiSignature { &self.signatures[&(idx as u8)], )?; verified_pks.insert(pk.clone()); + partial = true; } } }, } - Ok(()) - } -} - -/// A section representing the signature over another section -#[derive( - Clone, - Debug, - BorshSerialize, - BorshDeserialize, - BorshSchema, - Serialize, - Deserialize, -)] -pub struct Signature { - /// The hash of the section being signed - targets: Vec, - /// The signature over the above hashes - pub signature: Option, -} - -impl Signature { - pub fn new( - targets: Vec, - sec_key: &common::SecretKey, - ) -> Self { - let mut sec = Self { - targets, - signature: None, - }; - sec.signature = Some(common::SigScheme::sign(sec_key, sec.get_hash())); - sec - } - - /// Hash this signature section - pub fn hash<'a>(&self, hasher: &'a mut Sha256) -> &'a mut Sha256 { - hasher.update( - self.try_to_vec() - .expect("unable to serialize signature section"), - ); - hasher - } - - /// Get the hash of this section - pub fn get_hash(&self) -> crate::types::hash::Hash { - crate::types::hash::Hash( - self.hash(&mut Sha256::new()).finalize_reset().into(), - ) - } - - /// Verify that the signature contained in this section is valid - pub fn verify_signature( - &self, - public_key: &common::PublicKey, - ) -> std::result::Result<(), VerifySigError> { - let signature = - self.signature.as_ref().ok_or(VerifySigError::MissingData)?; - common::SigScheme::verify_signature( - public_key, - &Self { - signature: None, - ..self.clone() - } - .get_hash(), - signature, - ) + Ok(partial) } } @@ -949,8 +887,6 @@ pub enum Section { ExtraData(Code), /// Transaction code. Sending to hardware wallets optional Code(Code), - /// A transaction signature. Often produced by hardware wallets - SectionSignature(MultiSignature), /// A transaction header/protocol signature Signature(Signature), /// Ciphertext obtained by encrypting arbitrary transaction sections @@ -982,7 +918,6 @@ impl Section { Self::ExtraData(extra) => extra.hash(hasher), Self::Code(code) => code.hash(hasher), Self::Signature(signature) => signature.hash(hasher), - Self::SectionSignature(signatures) => signatures.hash(hasher), Self::Ciphertext(ct) => ct.hash(hasher), Self::MaspBuilder(mb) => mb.hash(hasher), Self::MaspTx(tx) => { @@ -1054,15 +989,6 @@ impl Section { } } - /// Extract the section signature from this section if possible - pub fn section_signature(&self) -> Option { - if let Self::SectionSignature(data) = self { - Some(data.clone()) - } else { - None - } - } - /// Extract the ciphertext from this section if possible pub fn ciphertext(&self) -> Option { if let Self::Ciphertext(data) = self { @@ -1395,59 +1321,57 @@ impl Tx { /// Verify that the section with the given hash has been signed by the given /// public key - pub fn verify_section_signatures( + pub fn verify_signatures( &self, hashes: &[crate::types::hash::Hash], public_keys_index_map: AccountPublicKeysMap, threshold: u8, max_signatures: Option, - gas_meter: &mut VpGasMeter, - ) -> std::result::Result<(), Error> { + mut gas_meter: Option<&mut VpGasMeter>, + ) -> std::result::Result, Error> { let max_signatures = max_signatures.unwrap_or(u8::MAX); let mut verified_pks = HashSet::new(); + let mut witnesses = Vec::new(); for section in &self.sections { - if let Section::SectionSignature(signatures) = section { - if !hashes.iter().all(|x| { + if let Section::Signature(signatures) = section { + // Check that the hashes being + // checked are a subset of those in this section + if hashes.iter().all(|x| { signatures.targets.contains(x) || section.get_hash() == *x }) { - return Err(Error::InvalidSectionSignature( - "missing target hash.".to_string(), - )); - } + // Ensure that all the sections the signature signs over are + // present + for target in &signatures.targets { + if self.get_section(target).is_none() { + return Err(Error::InvalidSectionSignature( + "Missing target section.".to_string(), + )); + } + } - for target in &signatures.targets { - if self.get_section(target).is_none() { + if signatures.total_signatures() > max_signatures { return Err(Error::InvalidSectionSignature( - "Missing target section.".to_string(), + "too many signatures.".to_string(), )); } - } - if signatures.total_signatures() > max_signatures { - return Err(Error::InvalidSectionSignature( - "too many signatures.".to_string(), - )); - } - - if signatures.total_signatures() < threshold { - return Err(Error::InvalidSectionSignature( - "too few signatures.".to_string(), - )); + // Finally verify that the signature itself is valid + if signatures + .verify_signature(&mut verified_pks, &public_keys_index_map) + .map_err(|_| Error::InvalidWrapperSignature)? + { + witnesses.push(signatures); + } + if let Some(x) = gas_meter.as_mut() { + x.consume(VERIFY_TX_SIG_GAS_COST * (signatures.total_signatures() as u64)) + .map_err(|_| Error::OutOfGas)?; + } } - - // Finally verify that the signature itself is valid - signatures - .verify_signature(&mut verified_pks, &public_keys_index_map) - .map_err(|_| Error::InvalidWrapperSignature)?; - gas_meter - .consume(VERIFY_TX_SIG_GAS_COST * (signatures.signatures.len() as u64)) - .map_err(|_| Error::OutOfGas)?; - } } if verified_pks.len() >= threshold.into() { - Ok(()) + Ok(witnesses) } else { Err(Error::InvalidSectionSignature( "invalid signatures.".to_string(), @@ -1463,31 +1387,13 @@ impl Tx { public_key: &common::PublicKey, hashes: &[crate::types::hash::Hash], ) -> Result<&Signature> { - for section in &self.sections { - if let Section::Signature(signature) = section { - // Check that the hashes being - // checked are a subset of those in this section - if hashes.iter().all(|x| { - signature.targets.contains(x) || section.get_hash() == *x - }) { - // Ensure that all the sections the signature signs over are - // present - for target in &signature.targets { - if self.get_section(target).is_none() { - return Err(Error::InvalidSectionSignature( - "Target section is missing.".to_string(), - )); - } - } - // Finally verify that the signature itself is valid - return signature - .verify_signature(public_key) - .map(|_| signature) - .map_err(|_| Error::InvalidWrapperSignature); - } - } - } - Err(Error::InvalidWrapperSignature) + self.verify_signatures( + hashes, + AccountPublicKeysMap::from_iter([public_key.clone()].into_iter()), + 1, + None, + None, + ).map(|x| *x.first().unwrap()) } /// Validate any and all ciphertexts stored in this transaction @@ -1514,7 +1420,7 @@ impl Tx { ) -> Vec { let targets = self.inner_section_targets(); let mut signatures = Vec::new(); - let section = MultiSignature::new( + let section = Signature::new( targets, public_keys_index_map.index_secret_keys(secret_keys.to_vec()), signer, @@ -1790,7 +1696,8 @@ impl Tx { self.protocol_filter(); self.add_section(Section::Signature(Signature::new( self.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); self } @@ -1804,7 +1711,7 @@ impl Tx { ) -> &mut Self { self.protocol_filter(); let hashes = self.inner_section_targets(); - self.add_section(Section::SectionSignature(MultiSignature::new( + self.add_section(Section::Signature(Signature::new( hashes, account_public_keys_map.index_secret_keys(keypairs), signer, @@ -1818,7 +1725,7 @@ impl Tx { signatures: Vec, ) -> &mut Self { self.protocol_filter(); - let mut pk_section = MultiSignature { + let mut pk_section = Signature { targets: self.inner_section_targets(), signatures: BTreeMap::new(), signer: Signer::PubKeys(vec![]), @@ -1828,7 +1735,7 @@ impl Tx { for signature in signatures { if let Some((addr, idx)) = &signature.index { // Add the signature under the given multisig address - let section = sections.entry(addr.clone()).or_insert_with(|| MultiSignature { + let section = sections.entry(addr.clone()).or_insert_with(|| Signature { targets: self.inner_section_targets(), signatures: BTreeMap::new(), signer: Signer::Address(addr.clone()), @@ -1841,7 +1748,7 @@ impl Tx { } } for section in std::iter::once(pk_section).chain(sections.into_values()) { - self.add_section(Section::SectionSignature(section)); + self.add_section(Section::Signature(section)); } self } diff --git a/core/src/types/transaction/mod.rs b/core/src/types/transaction/mod.rs index 6b00e4dfcc7..ce50e289889 100644 --- a/core/src/types/transaction/mod.rs +++ b/core/src/types/transaction/mod.rs @@ -168,7 +168,7 @@ impl TxType { #[cfg(test)] mod test_process_tx { use super::*; - use crate::proto::{Code, Data, Section, Signature, Tx, TxError}; + use crate::proto::{Code, Data, Signature, Section, Tx, TxError}; use crate::types::address::nam; use crate::types::key::*; use crate::types::storage::Epoch; @@ -235,7 +235,8 @@ mod test_process_tx { .clone(); tx.add_section(Section::Signature(Signature::new( vec![*tx.code_sechash(), *tx.data_sechash()], - &gen_keypair(), + [(0, gen_keypair())].into_iter().collect(), + None, ))); tx.validate_tx().expect("Test failed"); @@ -271,7 +272,8 @@ mod test_process_tx { tx.set_data(Data::new("transaction data".as_bytes().to_owned())); tx.add_section(Section::Signature(Signature::new( tx.sechashes(), - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); tx.validate_tx().expect("Test failed"); @@ -344,7 +346,7 @@ fn test_process_tx_decrypted_unsigned() { /// signature #[test] fn test_process_tx_decrypted_signed() { - use crate::proto::{Code, Data, Section, Signature, Tx}; + use crate::proto::{Code, Data, Signature, Section, Tx}; use crate::types::key::*; fn gen_keypair() -> common::SecretKey { @@ -365,8 +367,8 @@ fn test_process_tx_decrypted_signed() { let ed_sig = ed25519::Signature::try_from_slice([0u8; 64].as_ref()).unwrap(); let mut sig_sec = - Signature::new(vec![decrypted.header_hash()], &gen_keypair()); - sig_sec.signature = Some(common::Signature::try_from_sig(&ed_sig).unwrap()); + Signature::new(vec![decrypted.header_hash()], [(0, gen_keypair())].into_iter().collect(), None); + sig_sec.signatures.insert(0, common::Signature::try_from_sig(&ed_sig).unwrap()); decrypted.add_section(Section::Signature(sig_sec)); // create the tx with signed decrypted data let code_sec = decrypted diff --git a/core/src/types/transaction/protocol.rs b/core/src/types/transaction/protocol.rs index aa9abe8cec8..32e1eee65aa 100644 --- a/core/src/types/transaction/protocol.rs +++ b/core/src/types/transaction/protocol.rs @@ -32,7 +32,7 @@ mod protocol_txs { use serde_json; use super::*; - use crate::proto::{Code, Data, Section, Signature, Tx, TxError}; + use crate::proto::{Code, Data, Signature, Section, Tx, TxError}; use crate::types::chain::ChainId; use crate::types::key::*; use crate::types::transaction::{Digest, EllipticCurve, Sha256, TxType}; @@ -201,7 +201,8 @@ mod protocol_txs { outer_tx.set_data(Data::new(tx_data)); outer_tx.add_section(Section::Signature(Signature::new( outer_tx.sechashes(), - signing_key, + [(0, signing_key.clone())].into_iter().collect(), + None, ))); outer_tx } @@ -339,7 +340,8 @@ mod protocol_txs { *outer_tx.code_sechash(), *outer_tx.data_sechash(), ], - signing_key, + [(0, signing_key.clone())].into_iter().collect(), + None, ))); outer_tx } diff --git a/core/src/types/transaction/wrapper.rs b/core/src/types/transaction/wrapper.rs index bda7142220a..c7584b89555 100644 --- a/core/src/types/transaction/wrapper.rs +++ b/core/src/types/transaction/wrapper.rs @@ -414,7 +414,7 @@ pub mod wrapper_tx { #[cfg(test)] mod test_wrapper_tx { use super::*; - use crate::proto::{Code, Data, Section, Signature, Tx, TxError}; + use crate::proto::{Code, Data, Signature, Section, Tx, TxError}; use crate::types::address::nam; use crate::types::transaction::{Hash, TxType}; @@ -452,7 +452,8 @@ pub mod wrapper_tx { encrypted_tx.encrypt(&Default::default()); wrapper.add_section(Section::Signature(Signature::new( vec![wrapper.header_hash(), wrapper.sections[0].get_hash()], - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); assert!(encrypted_tx.validate_ciphertext()); let privkey = ::G2Affine::prime_subgroup_generator(); @@ -489,7 +490,8 @@ pub mod wrapper_tx { wrapper.encrypt(&Default::default()); wrapper.add_section(Section::Signature(Signature::new( vec![wrapper.header_hash(), wrapper.sections[0].get_hash()], - &keypair, + [(0, keypair)].into_iter().collect(), + None, ))); assert!(wrapper.validate_ciphertext()); let privkey = ::G2Affine::prime_subgroup_generator(); @@ -523,7 +525,8 @@ pub mod wrapper_tx { tx.set_data(Data::new("transaction data".as_bytes().to_owned())); tx.add_section(Section::Signature(Signature::new( tx.sechashes(), - &keypair, + [(0, keypair.clone())].into_iter().collect(), + None, ))); // we now try to alter the inner tx maliciously diff --git a/shared/src/ledger/ibc/vp/mod.rs b/shared/src/ledger/ibc/vp/mod.rs index 4e02cb229a5..91cc65e0b60 100644 --- a/shared/src/ledger/ibc/vp/mod.rs +++ b/shared/src/ledger/ibc/vp/mod.rs @@ -385,7 +385,7 @@ mod tests { use crate::ledger::parameters::EpochDuration; use crate::ledger::{ibc, pos}; use crate::proof_of_stake::parameters::PosParams; - use crate::proto::{Code, Data, Section, Signature, Tx}; + use crate::proto::{Code, Data, Signature, Section, Tx}; use crate::tendermint::time::Time as TmTime; use crate::tendermint_proto::Protobuf as TmProtobuf; use crate::types::key::testing::keypair_1; @@ -725,7 +725,8 @@ mod tests { outer_tx.set_data(Data::new(tx_data)); outer_tx.add_section(Section::Signature(Signature::new( vec![*outer_tx.code_sechash(), *outer_tx.data_sechash()], - &keypair_1(), + [(0, keypair_1())].into_iter().collect(), + None, ))); let ctx = Ctx::new( &ADDRESS, @@ -1037,7 +1038,8 @@ mod tests { outer_tx.set_data(Data::new(tx_data)); outer_tx.add_section(Section::Signature(Signature::new( vec![*outer_tx.code_sechash(), *outer_tx.data_sechash()], - &keypair_1(), + [(0, keypair_1())].into_iter().collect(), + None, ))); let gas_meter = VpGasMeter::new_from_tx_meter( &TxGasMeter::new_from_sub_limit(TX_GAS_LIMIT.into()), @@ -1370,7 +1372,8 @@ mod tests { outer_tx.set_data(Data::new(tx_data)); outer_tx.add_section(Section::Signature(Signature::new( vec![*outer_tx.code_sechash(), *outer_tx.data_sechash()], - &keypair_1(), + [(0, keypair_1())].into_iter().collect(), + None, ))); let gas_meter = VpGasMeter::new_from_tx_meter( &TxGasMeter::new_from_sub_limit(TX_GAS_LIMIT.into()), @@ -1457,7 +1460,8 @@ mod tests { outer_tx.set_data(Data::new(tx_data)); outer_tx.add_section(Section::Signature(Signature::new( vec![*outer_tx.code_sechash(), *outer_tx.data_sechash()], - &keypair_1(), + [(0, keypair_1())].into_iter().collect(), + None, ))); let gas_meter = VpGasMeter::new_from_tx_meter( &TxGasMeter::new_from_sub_limit(TX_GAS_LIMIT.into()), @@ -1581,7 +1585,8 @@ mod tests { outer_tx.set_data(Data::new(tx_data)); outer_tx.add_section(Section::Signature(Signature::new( vec![*outer_tx.code_sechash(), *outer_tx.data_sechash()], - &keypair_1(), + [(0, keypair_1())].into_iter().collect(), + None, ))); let gas_meter = VpGasMeter::new_from_tx_meter( &TxGasMeter::new_from_sub_limit(TX_GAS_LIMIT.into()), @@ -1704,7 +1709,8 @@ mod tests { outer_tx.set_data(Data::new(tx_data)); outer_tx.add_section(Section::Signature(Signature::new( vec![*outer_tx.code_sechash(), *outer_tx.data_sechash()], - &keypair_1(), + [(0, keypair_1())].into_iter().collect(), + None, ))); let gas_meter = VpGasMeter::new_from_tx_meter( &TxGasMeter::new_from_sub_limit(TX_GAS_LIMIT.into()), @@ -1812,7 +1818,8 @@ mod tests { outer_tx.set_data(Data::new(tx_data)); outer_tx.add_section(Section::Signature(Signature::new( vec![*outer_tx.code_sechash(), *outer_tx.data_sechash()], - &keypair_1(), + [(0, keypair_1())].into_iter().collect(), + None, ))); let gas_meter = VpGasMeter::new_from_tx_meter( &TxGasMeter::new_from_sub_limit(TX_GAS_LIMIT.into()), diff --git a/shared/src/ledger/native_vp/multitoken.rs b/shared/src/ledger/native_vp/multitoken.rs index 0d42e86eaa7..1ce44865ee8 100644 --- a/shared/src/ledger/native_vp/multitoken.rs +++ b/shared/src/ledger/native_vp/multitoken.rs @@ -150,7 +150,7 @@ mod tests { }; use crate::ledger::gas::VpGasMeter; use crate::ledger::ibc::storage::ibc_token; - use crate::proto::{Code, Data, Section, Signature, Tx}; + use crate::proto::{Code, Data, Signature, Section, Tx}; use crate::types::address::{Address, InternalAddress}; use crate::types::key::testing::keypair_1; use crate::types::storage::TxIndex; @@ -171,7 +171,8 @@ mod tests { tx.set_data(Data::new(tx_data)); tx.add_section(Section::Signature(Signature::new( tx.sechashes(), - &keypair_1(), + [(0, keypair_1())].into_iter().collect(), + None, ))); tx } diff --git a/shared/src/vm/host_env.rs b/shared/src/vm/host_env.rs index 179472a8906..e35ec9b7795 100644 --- a/shared/src/vm/host_env.rs +++ b/shared/src/vm/host_env.rs @@ -1839,12 +1839,12 @@ where let tx = unsafe { env.ctx.tx.get() }; Ok(HostEnvResult::from( - tx.verify_section_signatures( + tx.verify_signatures( &hashes, public_keys_map, threshold, max_signatures, - gas_meter, + Some(gas_meter), ) .is_ok(), ) diff --git a/tests/src/vm_host_env/mod.rs b/tests/src/vm_host_env/mod.rs index c8c105400e8..3ebcd959623 100644 --- a/tests/src/vm_host_env/mod.rs +++ b/tests/src/vm_host_env/mod.rs @@ -474,7 +474,7 @@ mod tests { assert_eq!(signed_tx_data.data().as_ref(), Some(data)); assert!( signed_tx_data - .verify_section_signatures( + .verify_signatures( &[ *signed_tx_data.data_sechash(), *signed_tx_data.code_sechash(), @@ -482,8 +482,8 @@ mod tests { pks_map, 1, None, - &mut VpGasMeter::new_from_tx_meter( - &TxGasMeter::new_from_sub_limit(u64::MAX.into()) + Some(&mut VpGasMeter::new_from_tx_meter( + &TxGasMeter::new_from_sub_limit(u64::MAX.into())) ) ) .is_ok() @@ -492,7 +492,7 @@ mod tests { let other_keypair = key::testing::keypair_2(); assert!( signed_tx_data - .verify_section_signatures( + .verify_signatures( &[ *signed_tx_data.data_sechash(), *signed_tx_data.code_sechash(), @@ -502,8 +502,8 @@ mod tests { ]), 1, None, - &mut VpGasMeter::new_from_tx_meter( - &TxGasMeter::new_from_sub_limit(u64::MAX.into()) + Some(&mut VpGasMeter::new_from_tx_meter( + &TxGasMeter::new_from_sub_limit(u64::MAX.into())) ) ) .is_err() diff --git a/wasm/checksums.json b/wasm/checksums.json index 45f369185d8..d3ec7f54c7f 100644 --- a/wasm/checksums.json +++ b/wasm/checksums.json @@ -1,23 +1,23 @@ { - "tx_bond.wasm": "tx_bond.340c5b40130afe30234e833ca56cc27e7d7682c9eeb6f6bec0aa9c1cc8ab8ba9.wasm", - "tx_bridge_pool.wasm": "tx_bridge_pool.9b546039f0d3186063564479d39908e7152c763e8eb403b8ffe1f1062f9d2581.wasm", - "tx_change_validator_commission.wasm": "tx_change_validator_commission.5e921f84f0ac90e498f013aee50f2bdab2989b642a8b1136d5350e3f81d8d5de.wasm", - "tx_ibc.wasm": "tx_ibc.198eee5e3e7bbb1d40770359910608d6f64ccc31ff155883a4fde9f0a43ee870.wasm", - "tx_init_account.wasm": "tx_init_account.fd06524b88d3198414e205371a3d502cfd490593afb7204cde77aa4461ab4298.wasm", - "tx_init_proposal.wasm": "tx_init_proposal.5d0b84ae5937a0debb30bc5d0725e405c6df9e83f35177a031a6f403cd69ad0e.wasm", - "tx_init_validator.wasm": "tx_init_validator.51c3e74cb99da446127a5b86261ee3688abef81a97aeeb69ab7bfad419982e81.wasm", - "tx_resign_steward.wasm": "tx_resign_steward.ddfa5cdf5450fb27fff7f9332c09d326ffc49ace1c6f86107b5bf5ff486ea18d.wasm", - "tx_reveal_pk.wasm": "tx_reveal_pk.3e0d19dd85d558bf193716696eea3bd51f923e13e750a9f47d3f69187bb1d3cf.wasm", - "tx_transfer.wasm": "tx_transfer.de1a50dd240b47f8cb8c8908ca2a1d5a7bdf5666f6ab89755ec766b86d511c3b.wasm", - "tx_unbond.wasm": "tx_unbond.1b280628bfa88bd5da7086f72d5c8dd110a41bfdf265aef9bd24f55aebc457ba.wasm", - "tx_unjail_validator.wasm": "tx_unjail_validator.459c700dc2104fd1352f612d2b5ef7e921fc25fcd1d5a6ef23d66d8362656803.wasm", - "tx_update_account.wasm": "tx_update_account.552882be607d5c85b62d83198346751a318aba48a85a411c550e29f158dd5ab8.wasm", - "tx_update_steward_commission.wasm": "tx_update_steward_commission.a30918eb4a73169bc6649c0872e2a5c48347ff2f2c2c77cf245c271b9617c679.wasm", - "tx_vote_proposal.wasm": "tx_vote_proposal.fb1060580449efeb7ee4bb2f94dd821d04dc1c6bc113505129455f5961c19def.wasm", - "tx_withdraw.wasm": "tx_withdraw.6b62ccb81c2ec4ca6f753b847f231afe1280a710413bdb29c40022f76c8a4c31.wasm", - "vp_implicit.wasm": "vp_implicit.0b24ed30523cf07e313eb909a543fdaa781ece0edb0a730afa1096b0b3f2f84e.wasm", - "vp_masp.wasm": "vp_masp.9fce62466516b80d0d4b9f70818e2043c199d3ccde8e15388ebb8ef84d2211ca.wasm", - "vp_testnet_faucet.wasm": "vp_testnet_faucet.e04deff5842fe2168e077fc880352eb04ff53036e9e1025b9040456d02cf85fd.wasm", - "vp_user.wasm": "vp_user.242e0ad72e300d8315b8e9df667025c16216d16726c3e7f0467f036f85ba5bda.wasm", - "vp_validator.wasm": "vp_validator.0acfc199bfcd51fb07f4b5ad2f101f8c2cdf4d907b5c7732f96e66d50ff184e1.wasm" + "tx_bond.wasm": "tx_bond.645bed977362f1bfbea4e013535feae73a98bb1e5ddd8d4ac8545d6fbd831d62.wasm", + "tx_bridge_pool.wasm": "tx_bridge_pool.fcd49f87e32c0b975702f804bc4fe80be180e653e1327bc6610dd0d27cba018b.wasm", + "tx_change_validator_commission.wasm": "tx_change_validator_commission.501fa4c9e670c4053321e654a08204827ed0f4c506936028346d11cf57bd6b00.wasm", + "tx_ibc.wasm": "tx_ibc.64adcac57a8d24950993009a8ae6814634c2b39037b375d09925eddeffad8fb1.wasm", + "tx_init_account.wasm": "tx_init_account.bc58fce056aac0d2563e01a5ec621fc6b906ab83ad759ad0bfbd2ba9abfcd7d2.wasm", + "tx_init_proposal.wasm": "tx_init_proposal.61103c6914a72780a32a336258933370d8323585c783b2dc3f5c1e2fd6a9079d.wasm", + "tx_init_validator.wasm": "tx_init_validator.4f36cd75e13213916d4a581c33ba16043c77eb5c0e2d4732ffca54140e031c15.wasm", + "tx_resign_steward.wasm": "tx_resign_steward.2ef1646b0ddd96780ac2e28544e5b0bade239f0d35ca4822a37a7baf84579dae.wasm", + "tx_reveal_pk.wasm": "tx_reveal_pk.6509b61dd706789f63328ec426fd0f8a58c9fecdbb12f87b45f72069968469e7.wasm", + "tx_transfer.wasm": "tx_transfer.a21f1a2078aa3eebc57454510f7ed3097be6e9cf283d954d59dee66af2d360fd.wasm", + "tx_unbond.wasm": "tx_unbond.b05e386d5bb8318bdf333389ded53db20b63d992a2c9c08e1c12a8cae479aba2.wasm", + "tx_unjail_validator.wasm": "tx_unjail_validator.3fef792673c9e05f1f9f4546d98d9801b8ae31143db43e46356ef0304c988e2a.wasm", + "tx_update_account.wasm": "tx_update_account.9021b556106c6749d27eb4d3c7b9503e15a918c904e0bd6fbf414fdb2409be5a.wasm", + "tx_update_steward_commission.wasm": "tx_update_steward_commission.5a1815d10bd716c2955aa34a69e928526efa360649b036e9ca82ff92c150285e.wasm", + "tx_vote_proposal.wasm": "tx_vote_proposal.4dcab25b11de06b12944439b73f657f23dd1cde55aba13ad0afbb5421382eba6.wasm", + "tx_withdraw.wasm": "tx_withdraw.9b35f2ecb0ed3287c97f9c43c5f5f04161a09d75a09d123bb9706d6a9ee31efc.wasm", + "vp_implicit.wasm": "vp_implicit.185ba7eadb1ab386714bd3266cc2cbb44faa3fe1f7bc1a019d678551faf36a81.wasm", + "vp_masp.wasm": "vp_masp.804ecad1cb7c5de9aebd26945c111a586ed749ddbe3ea897d84a9aa828a5920f.wasm", + "vp_testnet_faucet.wasm": "vp_testnet_faucet.215e855aea7ac4d23a451c5c860538360e95f46b49fa305dafcc5af6794c344e.wasm", + "vp_user.wasm": "vp_user.d1bc1fd1019335924d41aed65a598f123a4d8d200a0ba289fa3ec58553c8cb4e.wasm", + "vp_validator.wasm": "vp_validator.d5670e36c587ae9d233de1b5e574fd14dabee7e6405ad9fd1cb8d0f858be6d08.wasm" } \ No newline at end of file diff --git a/wasm/wasm_source/src/vp_implicit.rs b/wasm/wasm_source/src/vp_implicit.rs index 09a3d32ba7d..215dccf421d 100644 --- a/wasm/wasm_source/src/vp_implicit.rs +++ b/wasm/wasm_source/src/vp_implicit.rs @@ -187,7 +187,7 @@ fn validate_tx( mod tests { // Use this as `#[test]` annotation to enable logging use namada::ledger::pos::{GenesisValidator, PosParams}; - use namada::proto::{Code, Data, MultiSignature}; + use namada::proto::{Code, Data, Signature}; use namada::types::dec::Dec; use namada::types::storage::Epoch; use namada::types::transaction::TxType; @@ -535,7 +535,7 @@ mod tests { let mut tx = vp_env.tx.clone(); tx.set_data(Data::new(vec![])); tx.set_code(Code::new(vec![])); - tx.add_section(Section::SectionSignature(MultiSignature::new( + tx.add_section(Section::Signature(Signature::new( vec![*tx.data_sechash(), *tx.code_sechash()], pks_map.index_secret_keys(vec![secret_key]), None, @@ -671,7 +671,7 @@ mod tests { let mut tx = vp_env.tx.clone(); tx.set_data(Data::new(vec![])); tx.set_code(Code::new(vec![])); - tx.add_section(Section::SectionSignature(MultiSignature::new( + tx.add_section(Section::Signature(Signature::new( vec![*tx.data_sechash(), *tx.code_sechash()], pks_map.index_secret_keys(vec![secret_key]), None, @@ -839,7 +839,7 @@ mod tests { let mut tx = vp_env.tx.clone(); tx.set_data(Data::new(vec![])); tx.set_code(Code::new(vec![])); - tx.add_section(Section::SectionSignature(MultiSignature::new( + tx.add_section(Section::Signature(Signature::new( vec![*tx.data_sechash(), *tx.code_sechash()], pks_map.index_secret_keys(vec![secret_key]), None, @@ -932,7 +932,7 @@ mod tests { let mut tx = vp_env.tx.clone(); tx.set_data(Data::new(vec![])); tx.set_code(Code::new(vec![])); - tx.add_section(Section::SectionSignature(MultiSignature::new( + tx.add_section(Section::Signature(Signature::new( vec![*tx.data_sechash(), *tx.code_sechash()], pks_map.index_secret_keys(vec![secret_key]), None, @@ -987,7 +987,7 @@ mod tests { let mut tx = vp_env.tx.clone(); tx.set_code(Code::new(vec![])); tx.set_data(Data::new(vec![])); - tx.add_section(Section::SectionSignature(MultiSignature::new( + tx.add_section(Section::Signature(Signature::new( vec![*tx.data_sechash(), *tx.code_sechash()], pks_map.index_secret_keys(vec![secret_key]), None, diff --git a/wasm/wasm_source/src/vp_testnet_faucet.rs b/wasm/wasm_source/src/vp_testnet_faucet.rs index 53b039c81d3..7298c0b1260 100644 --- a/wasm/wasm_source/src/vp_testnet_faucet.rs +++ b/wasm/wasm_source/src/vp_testnet_faucet.rs @@ -108,7 +108,7 @@ fn validate_tx( #[cfg(test)] mod tests { use address::testing::arb_non_internal_address; - use namada::proto::{Code, Data, MultiSignature, Signature}; + use namada::proto::{Code, Data, Signature}; use namada::types::transaction::TxType; use namada_test_utils::TestWasms; // Use this as `#[test]` annotation to enable logging @@ -266,7 +266,7 @@ mod tests { let mut tx = vp_env.tx.clone(); tx.set_data(Data::new(vec![])); tx.set_code(Code::new(vec![])); - tx.add_section(Section::SectionSignature(MultiSignature::new( + tx.add_section(Section::Signature(Signature::new( vec![*tx.data_sechash(), *tx.code_sechash()], pks_map.index_secret_keys(vec![keypair]), None, @@ -399,7 +399,11 @@ mod tests { let mut tx_data = Tx::from_type(TxType::Raw); tx_data.set_data(Data::new(solution_bytes)); tx_data.set_code(Code::new(vec![])); - tx_data.add_section(Section::Signature(Signature::new(vec![*tx_data.data_sechash(), *tx_data.code_sechash()], &target_key))); + tx_data.add_section(Section::Signature(Signature::new( + vec![*tx_data.data_sechash(), *tx_data.code_sechash()], + [(0, target_key)].into_iter().collect(), + None, + ))); let keys_changed: BTreeSet = vp_env.all_touched_storage_keys(); let verifiers: BTreeSet
= BTreeSet::default(); @@ -449,7 +453,7 @@ mod tests { let mut tx = vp_env.tx.clone(); tx.set_data(Data::new(vec![])); tx.set_code(Code::new(vec![])); - tx.add_section(Section::SectionSignature(MultiSignature::new( + tx.add_section(Section::Signature(Signature::new( vec![*tx.data_sechash(), *tx.code_sechash()], pks_map.index_secret_keys(vec![keypair]), None, diff --git a/wasm/wasm_source/src/vp_user.rs b/wasm/wasm_source/src/vp_user.rs index 6e5bd024a37..a334576b530 100644 --- a/wasm/wasm_source/src/vp_user.rs +++ b/wasm/wasm_source/src/vp_user.rs @@ -185,7 +185,7 @@ fn validate_tx( mod tests { use address::testing::arb_non_internal_address; use namada::ledger::pos::{GenesisValidator, PosParams}; - use namada::proto::{Code, Data, MultiSignature}; + use namada::proto::{Code, Data, Signature}; use namada::types::dec::Dec; use namada::types::storage::Epoch; use namada::types::transaction::TxType; @@ -392,7 +392,7 @@ mod tests { let mut tx = vp_env.tx.clone(); tx.set_data(Data::new(vec![])); tx.set_code(Code::new(vec![])); - tx.add_section(Section::SectionSignature(MultiSignature::new( + tx.add_section(Section::Signature(Signature::new( vec![*tx.data_sechash(), *tx.code_sechash()], pks_map.index_secret_keys(vec![keypair]), None, @@ -561,7 +561,7 @@ mod tests { let mut tx = vp_env.tx.clone(); tx.set_data(Data::new(vec![])); tx.set_code(Code::new(vec![])); - tx.add_section(Section::SectionSignature(MultiSignature::new( + tx.add_section(Section::Signature(Signature::new( vec![*tx.data_sechash(), *tx.code_sechash()], pks_map.index_secret_keys(vec![secret_key]), None, @@ -723,7 +723,7 @@ mod tests { let mut tx = vp_env.tx.clone(); tx.set_code(Code::new(vec![])); tx.set_data(Data::new(vec![])); - tx.add_section(Section::SectionSignature(MultiSignature::new( + tx.add_section(Section::Signature(Signature::new( vec![*tx.data_sechash(), *tx.code_sechash()], pks_map.index_secret_keys(vec![keypair]), None, @@ -810,7 +810,7 @@ mod tests { let mut tx = vp_env.tx.clone(); tx.set_data(Data::new(vec![])); tx.set_code(Code::new(vec![])); - tx.add_section(Section::SectionSignature(MultiSignature::new( + tx.add_section(Section::Signature(Signature::new( vec![*tx.data_sechash(), *tx.code_sechash()], pks_map.index_secret_keys(vec![keypair]), None, @@ -865,7 +865,7 @@ mod tests { let mut tx = vp_env.tx.clone(); tx.set_data(Data::new(vec![])); tx.set_code(Code::new(vec![])); - tx.add_section(Section::SectionSignature(MultiSignature::new( + tx.add_section(Section::Signature(Signature::new( vec![*tx.data_sechash(), *tx.code_sechash()], pks_map.index_secret_keys(vec![keypair]), None, @@ -921,7 +921,7 @@ mod tests { let mut tx = vp_env.tx.clone(); tx.set_data(Data::new(vec![])); tx.set_code(Code::new(vec![])); - tx.add_section(Section::SectionSignature(MultiSignature::new( + tx.add_section(Section::Signature(Signature::new( vec![*tx.data_sechash(), *tx.code_sechash()], pks_map.index_secret_keys(vec![keypair]), None, @@ -977,7 +977,7 @@ mod tests { let mut tx = vp_env.tx.clone(); tx.set_data(Data::new(vec![])); tx.set_code(Code::new(vec![])); - tx.add_section(Section::SectionSignature(MultiSignature::new( + tx.add_section(Section::Signature(Signature::new( vec![*tx.data_sechash(), *tx.code_sechash()], pks_map.index_secret_keys(vec![keypair]), None, @@ -1033,7 +1033,7 @@ mod tests { let mut tx = vp_env.tx.clone(); tx.set_code(Code::new(vec![])); tx.set_data(Data::new(vec![])); - tx.add_section(Section::SectionSignature(MultiSignature::new( + tx.add_section(Section::Signature(Signature::new( vec![*tx.data_sechash(), *tx.code_sechash()], pks_map.index_secret_keys(vec![keypair]), None, diff --git a/wasm/wasm_source/src/vp_validator.rs b/wasm/wasm_source/src/vp_validator.rs index 6325f1de240..f929a8a0d1e 100644 --- a/wasm/wasm_source/src/vp_validator.rs +++ b/wasm/wasm_source/src/vp_validator.rs @@ -192,7 +192,7 @@ fn validate_tx( mod tests { use address::testing::arb_non_internal_address; use namada::ledger::pos::{GenesisValidator, PosParams}; - use namada::proto::{Code, Data, MultiSignature}; + use namada::proto::{Code, Data, Signature}; use namada::types::dec::Dec; use namada::types::storage::Epoch; use namada::types::transaction::TxType; @@ -399,7 +399,7 @@ mod tests { let mut tx = vp_env.tx.clone(); tx.set_data(Data::new(vec![])); tx.set_code(Code::new(vec![])); - tx.add_section(Section::SectionSignature(MultiSignature::new( + tx.add_section(Section::Signature(Signature::new( vec![*tx.data_sechash(), *tx.code_sechash()], pks_map.index_secret_keys(vec![keypair]), None, @@ -579,7 +579,7 @@ mod tests { let mut tx = vp_env.tx.clone(); tx.set_data(Data::new(vec![])); tx.set_code(Code::new(vec![])); - tx.add_section(Section::SectionSignature(MultiSignature::new( + tx.add_section(Section::Signature(Signature::new( vec![*tx.data_sechash(), *tx.code_sechash()], pks_map.index_secret_keys(vec![secret_key]), None, @@ -741,7 +741,7 @@ mod tests { let mut tx = vp_env.tx.clone(); tx.set_data(Data::new(vec![])); tx.set_code(Code::new(vec![])); - tx.add_section(Section::SectionSignature(MultiSignature::new( + tx.add_section(Section::Signature(Signature::new( vec![*tx.data_sechash(), *tx.code_sechash()], pks_map.index_secret_keys(vec![keypair]), None, @@ -827,7 +827,7 @@ mod tests { let mut tx = vp_env.tx.clone(); tx.set_data(Data::new(vec![])); tx.set_code(Code::new(vec![])); - tx.add_section(Section::SectionSignature(MultiSignature::new( + tx.add_section(Section::Signature(Signature::new( vec![*tx.data_sechash(), *tx.code_sechash()], pks_map.index_secret_keys(vec![keypair]), None, @@ -882,7 +882,7 @@ mod tests { let mut tx = vp_env.tx.clone(); tx.set_data(Data::new(vec![])); tx.set_code(Code::new(vec![])); - tx.add_section(Section::SectionSignature(MultiSignature::new( + tx.add_section(Section::Signature(Signature::new( vec![*tx.data_sechash(), *tx.code_sechash()], pks_map.index_secret_keys(vec![keypair]), None, @@ -938,7 +938,7 @@ mod tests { let mut tx = vp_env.tx.clone(); tx.set_data(Data::new(vec![])); tx.set_code(Code::new(vec![])); - tx.add_section(Section::SectionSignature(MultiSignature::new( + tx.add_section(Section::Signature(Signature::new( vec![*tx.data_sechash(), *tx.code_sechash()], pks_map.index_secret_keys(vec![keypair]), None, @@ -994,7 +994,7 @@ mod tests { let mut tx = vp_env.tx.clone(); tx.set_data(Data::new(vec![])); tx.set_code(Code::new(vec![])); - tx.add_section(Section::SectionSignature(MultiSignature::new( + tx.add_section(Section::Signature(Signature::new( vec![*tx.data_sechash(), *tx.code_sechash()], pks_map.index_secret_keys(vec![keypair]), None, @@ -1050,7 +1050,7 @@ mod tests { let mut tx = vp_env.tx.clone(); tx.set_code(Code::new(vec![])); tx.set_data(Data::new(vec![])); - tx.add_section(Section::SectionSignature(MultiSignature::new( + tx.add_section(Section::Signature(Signature::new( vec![*tx.data_sechash(), *tx.code_sechash()], pks_map.index_secret_keys(vec![keypair]), None, diff --git a/wasm_for_tests/tx_memory_limit.wasm b/wasm_for_tests/tx_memory_limit.wasm index 8e8165038dc..a3c46516103 100755 Binary files a/wasm_for_tests/tx_memory_limit.wasm and b/wasm_for_tests/tx_memory_limit.wasm differ diff --git a/wasm_for_tests/tx_mint_tokens.wasm b/wasm_for_tests/tx_mint_tokens.wasm index adb1e921ece..753a67c6d89 100755 Binary files a/wasm_for_tests/tx_mint_tokens.wasm and b/wasm_for_tests/tx_mint_tokens.wasm differ diff --git a/wasm_for_tests/tx_no_op.wasm b/wasm_for_tests/tx_no_op.wasm index 85b647c477f..9762fc4a558 100755 Binary files a/wasm_for_tests/tx_no_op.wasm and b/wasm_for_tests/tx_no_op.wasm differ diff --git a/wasm_for_tests/tx_proposal_code.wasm b/wasm_for_tests/tx_proposal_code.wasm index 238272934fe..c4622984360 100755 Binary files a/wasm_for_tests/tx_proposal_code.wasm and b/wasm_for_tests/tx_proposal_code.wasm differ diff --git a/wasm_for_tests/tx_read_storage_key.wasm b/wasm_for_tests/tx_read_storage_key.wasm index f1bbcbceb9a..68c84f470fd 100755 Binary files a/wasm_for_tests/tx_read_storage_key.wasm and b/wasm_for_tests/tx_read_storage_key.wasm differ diff --git a/wasm_for_tests/tx_write.wasm b/wasm_for_tests/tx_write.wasm index 048f3a46dbe..7a94279f165 100755 Binary files a/wasm_for_tests/tx_write.wasm and b/wasm_for_tests/tx_write.wasm differ diff --git a/wasm_for_tests/tx_write_storage_key.wasm b/wasm_for_tests/tx_write_storage_key.wasm index 5d600d185f1..a0fb758ae96 100755 Binary files a/wasm_for_tests/tx_write_storage_key.wasm and b/wasm_for_tests/tx_write_storage_key.wasm differ diff --git a/wasm_for_tests/vp_always_false.wasm b/wasm_for_tests/vp_always_false.wasm index 2c2f150abc4..c00f25615e2 100755 Binary files a/wasm_for_tests/vp_always_false.wasm and b/wasm_for_tests/vp_always_false.wasm differ diff --git a/wasm_for_tests/vp_always_true.wasm b/wasm_for_tests/vp_always_true.wasm index 635dad5ea63..0f53b421990 100755 Binary files a/wasm_for_tests/vp_always_true.wasm and b/wasm_for_tests/vp_always_true.wasm differ diff --git a/wasm_for_tests/vp_eval.wasm b/wasm_for_tests/vp_eval.wasm index bfab45916fe..fe7e886d53b 100755 Binary files a/wasm_for_tests/vp_eval.wasm and b/wasm_for_tests/vp_eval.wasm differ diff --git a/wasm_for_tests/vp_memory_limit.wasm b/wasm_for_tests/vp_memory_limit.wasm index 9b9c113e606..a186ecf733e 100755 Binary files a/wasm_for_tests/vp_memory_limit.wasm and b/wasm_for_tests/vp_memory_limit.wasm differ diff --git a/wasm_for_tests/vp_read_storage_key.wasm b/wasm_for_tests/vp_read_storage_key.wasm index 240d434d3aa..a6d29b07aa0 100755 Binary files a/wasm_for_tests/vp_read_storage_key.wasm and b/wasm_for_tests/vp_read_storage_key.wasm differ