From b6572e69ade9ba73a88af89b5533bd65a997dc32 Mon Sep 17 00:00:00 2001 From: Cashmaney Date: Thu, 1 Jun 2023 10:02:57 +0300 Subject: [PATCH] Verify new message type2 (#1452) * Add validation for new message type --- cosmwasm/enclaves/Cargo.lock | 7 + .../execute/src/registration/onchain.rs | 12 + .../enclaves/shared/block-verifier/Cargo.toml | 4 +- .../enclaves/shared/block-verifier/src/lib.rs | 5 + .../src/submit_block_signatures.rs | 2 +- .../shared/block-verifier/src/verify/mod.rs | 7 +- .../block-verifier/src/verify/registration.rs | 35 ++ .../block-verifier/src/wasm_messages.rs | 61 +- .../enclaves/shared/cosmos-proto/build.rs | 12 + .../enclaves/shared/cosmos-proto/src/lib.rs | 6 + .../src/registration/v1beta1/msg.rs | 568 ++++++++++++++++++ x/registration/internal/keeper/keeper.go | 1 + 12 files changed, 712 insertions(+), 8 deletions(-) create mode 100644 cosmwasm/enclaves/shared/block-verifier/src/verify/registration.rs create mode 100644 cosmwasm/enclaves/shared/cosmos-proto/src/registration/v1beta1/msg.rs diff --git a/cosmwasm/enclaves/Cargo.lock b/cosmwasm/enclaves/Cargo.lock index 00183ca2f..5ab438edc 100644 --- a/cosmwasm/enclaves/Cargo.lock +++ b/cosmwasm/enclaves/Cargo.lock @@ -116,6 +116,12 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "base64" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f1e31e207a6b8fb791a38ea3105e6cb541f55e4d029902d3039a4ad07cc4105" + [[package]] name = "bech32" version = "0.7.3" @@ -209,6 +215,7 @@ dependencies = [ name = "block-verifier" version = "0.1.0" dependencies = [ + "base64 0.21.1", "cosmos_proto", "enclave_crypto", "enclave_utils", diff --git a/cosmwasm/enclaves/execute/src/registration/onchain.rs b/cosmwasm/enclaves/execute/src/registration/onchain.rs index fa85cfd9e..12bc957d3 100644 --- a/cosmwasm/enclaves/execute/src/registration/onchain.rs +++ b/cosmwasm/enclaves/execute/src/registration/onchain.rs @@ -17,6 +17,12 @@ use enclave_utils::{ use super::cert::verify_ra_cert; use super::seed_exchange::encrypt_seed; +#[cfg(feature = "light-client-validation")] +use block_verifier::VERIFIED_MESSAGES; + +#[cfg(feature = "light-client-validation")] +use block_verifier::registration::verify_reg_msg; + /// /// `ecall_authenticate_new_node` /// @@ -45,8 +51,14 @@ pub unsafe extern "C" fn ecall_authenticate_new_node( validate_mut_ptr!(seed.as_mut_ptr(), seed.len(), NodeAuthResult::InvalidInput); validate_const_ptr!(cert, cert_len as usize, NodeAuthResult::InvalidInput); + let cert_slice = std::slice::from_raw_parts(cert, cert_len as usize); + #[cfg(feature = "light-client-validation")] + if !verify_reg_msg(cert_slice) { + return NodeAuthResult::SignatureInvalid; + } + let result = panic::catch_unwind(|| -> Result, NodeAuthResult> { // verify certificate, and return the public key in the extra data of the report let pk = verify_ra_cert(cert_slice, None)?; diff --git a/cosmwasm/enclaves/shared/block-verifier/Cargo.toml b/cosmwasm/enclaves/shared/block-verifier/Cargo.toml index 6bc1f4d51..ca30422b3 100644 --- a/cosmwasm/enclaves/shared/block-verifier/Cargo.toml +++ b/cosmwasm/enclaves/shared/block-verifier/Cargo.toml @@ -5,7 +5,7 @@ edition = "2018" [features] default = ["random"] -test = [] +test = ["base64"] random = [] production = [] verify-validator-whitelist = [] @@ -32,6 +32,8 @@ cosmos_proto = {path="../cosmos-proto"} protobuf = { version = "2.25.2" } hex = { version = "0.4.3" } +base64 = { version = "0.21.0", optional = true } + # cosmrs = { version = "0.11.0", default-features = false } diff --git a/cosmwasm/enclaves/shared/block-verifier/src/lib.rs b/cosmwasm/enclaves/shared/block-verifier/src/lib.rs index 49671af1b..b8cc4e135 100644 --- a/cosmwasm/enclaves/shared/block-verifier/src/lib.rs +++ b/cosmwasm/enclaves/shared/block-verifier/src/lib.rs @@ -10,6 +10,8 @@ pub mod wasm_messages; pub use wasm_messages::VERIFIED_MESSAGES; +pub use verify::registration; + mod txs; #[cfg(any(feature = "verify-validator-whitelist", feature = "test"))] @@ -51,6 +53,9 @@ pub mod tests { crate::wasm_messages::tests::parse_tx_multiple_msg_non_wasm(); crate::wasm_messages::tests::parse_tx_multisig(); crate::wasm_messages::tests::check_message_is_wasm(); + crate::wasm_messages::tests::check_message_is_reg(); + crate::wasm_messages::tests::check_parse_reg_bytes(); + crate::wasm_messages::tests::check_parse_reg_from_tx(); crate::wasm_messages::tests::test_check_message_not_wasm(); crate::wasm_messages::tests::test_wasm_msg_tracker(); crate::wasm_messages::tests::test_wasm_msg_tracker_multiple_msgs(); diff --git a/cosmwasm/enclaves/shared/block-verifier/src/submit_block_signatures.rs b/cosmwasm/enclaves/shared/block-verifier/src/submit_block_signatures.rs index a99c24281..a2a9d6373 100644 --- a/cosmwasm/enclaves/shared/block-verifier/src/submit_block_signatures.rs +++ b/cosmwasm/enclaves/shared/block-verifier/src/submit_block_signatures.rs @@ -120,7 +120,7 @@ pub unsafe fn submit_block_signatures_impl( sgx_status_t::SGX_ERROR_INVALID_PARAMETER })); - message_verifier.append_wasm_from_tx(parsed_tx); + message_verifier.append_msg_from_tx(parsed_tx); } message_verifier.set_block_info( diff --git a/cosmwasm/enclaves/shared/block-verifier/src/verify/mod.rs b/cosmwasm/enclaves/shared/block-verifier/src/verify/mod.rs index 72ee509d4..1c0b71773 100644 --- a/cosmwasm/enclaves/shared/block-verifier/src/verify/mod.rs +++ b/cosmwasm/enclaves/shared/block-verifier/src/verify/mod.rs @@ -1,8 +1,11 @@ -pub mod txs; -pub mod validator_set; pub mod block; pub mod commit; pub mod header; +pub mod txs; +pub mod validator_set; #[cfg(feature = "random")] pub mod random; + +// external messages +pub mod registration; diff --git a/cosmwasm/enclaves/shared/block-verifier/src/verify/registration.rs b/cosmwasm/enclaves/shared/block-verifier/src/verify/registration.rs new file mode 100644 index 000000000..8b0612950 --- /dev/null +++ b/cosmwasm/enclaves/shared/block-verifier/src/verify/registration.rs @@ -0,0 +1,35 @@ +use crate::VERIFIED_MESSAGES; +use log::{debug, error}; +use protobuf::Message; + +pub fn verify_reg_msg(certificate: &[u8]) -> bool { + let mut verified_msgs = VERIFIED_MESSAGES.lock().unwrap(); + let next = verified_msgs.get_next(); + + let result = if let Some(msg) = next { + match cosmos_proto::registration::v1beta1::msg::RaAuthenticate::parse_from_bytes(&msg) { + Ok(ra_msg) => { + if ra_msg.certificate == certificate { + return true; + } + error!("Error failed to validate registration message - 0x7535"); + false + } + Err(e) => { + debug!("Error decoding registation protobuf: {}", e); + error!("Error decoding msg from block validator - 0xA0F2"); + false + } + } + } else { + error!("Cannot verify new node unless msg is part of the current block"); + false + }; + + if !result { + // if validation failed clear the message queue and prepare for next tx... or apphash + verified_msgs.clear(); + } + + result +} diff --git a/cosmwasm/enclaves/shared/block-verifier/src/wasm_messages.rs b/cosmwasm/enclaves/shared/block-verifier/src/wasm_messages.rs index 7cbcbfc47..f43b2eaa2 100644 --- a/cosmwasm/enclaves/shared/block-verifier/src/wasm_messages.rs +++ b/cosmwasm/enclaves/shared/block-verifier/src/wasm_messages.rs @@ -12,6 +12,13 @@ pub fn message_is_wasm(msg: &protobuf::well_known_types::Any) -> bool { ) } +pub fn message_is_reg(msg: &protobuf::well_known_types::Any) -> bool { + matches!( + msg.type_url.as_str(), + "/secret.registration.v1beta1.RaAuthenticate" + ) +} + #[derive(Debug, Clone, Default)] pub struct VerifiedWasmMessages { messages: VecDeque>, @@ -28,9 +35,9 @@ impl VerifiedWasmMessages { self.messages.len() } - pub fn append_wasm_from_tx(&mut self, mut tx: Tx) { + pub fn append_msg_from_tx(&mut self, mut tx: Tx) { for msg in tx.take_body().messages { - if message_is_wasm(&msg) { + if message_is_wasm(&msg) | message_is_reg(&msg) { self.messages.push_back(msg.value); } } @@ -61,6 +68,7 @@ lazy_static! { #[cfg(feature = "test")] pub mod tests { + use base64; use cosmos_proto::tx as protoTx; use hex; use protobuf::Message; @@ -70,6 +78,8 @@ pub mod tests { const TX_RAW_2_WASM_1_BANK_MSG: &str = "0ad0050a97020a2a2f7365637265742e636f6d707574652e763162657461312e4d736745786563757465436f6e747261637412e8010a1406a918f7c66a8f4182f4a6304f8600c98261484712143b1a7485c6162c5883ee45fb2d7477a87d8a4ce51a9e01f1f5895860fbfc3f849e6349b801d19c6d430c64edd37c660b18f1a82f08d3ee5f652f4faed2125bccac7851d95f906c6cb36c4132b65d6c86adf76466e3543a9ac4ec5f75c7af3318a3fd66fa1a2e8747344bf02dc0e128b05ccdbac74a8b19e22957ecf787a40928091bd39e5cd2267ec477d0e5280ae6351497601b97ec79dacf22250cd79d991d9026c17258f517cc1b864d15dc510a1bf70c8022e82a0c0a05617373616612033133302a0b0a0564656e6f6d120231350a97020a2a2f7365637265742e636f6d707574652e763162657461312e4d736745786563757465436f6e747261637412e8010a1406a918f7c66a8f4182f4a6304f8600c98261484712143b1a7485c6162c5883ee45fb2d7477a87d8a4ce51a9e01f1f5895860fbfc3f849e6349b801d19c6d430c64edd37c660b18f1a82f08d3ee5f652f4faed2125bccac7851d95f906c6cb36c4132b65d6c86adf76466e3543a9ac4ec5f75c7af3318a3fd66fa1a2e8747344bf02dc0e128b05ccdbac74a8b19e22957ecf787a40928091bd39e5cd2267ec477d0e5280ae6351497601b97ec79dacf22250cd79d991d9026c17258f517cc1b864d15dc510a1bf70c8022e82a0c0a05617373616612033133302a0b0a0564656e6f6d120231350a99010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412790a2d7365637265743171363533336137786432383572716835356363796c707371657870787a6a7a38717a6e386e38122d7365637265743171363533336137786432383572716835356363796c707371657870787a6a7a38717a6e386e381a0c0a05617373616612033133301a0b0a0564656e6f6d1202313512f2010a4e0a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103d3c85ce8007e9a745e5dc986aa721289da524c08adee427cbc58d0a0b015eaf012040a0208010a4e0a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103d3c85ce8007e9a745e5dc986aa721289da524c08adee427cbc58d0a0b015eaf012040a0208010a4e0a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103d3c85ce8007e9a745e5dc986aa721289da524c08adee427cbc58d0a0b015eaf012040a02080112001a40d95940e2c70ed12f223dce90e1f89f357cabdc16e234467cc2534e4554c804004b8457db52af71228726b170fa7c897352eec906e9a948ef327182725f01192a1a40d95940e2c70ed12f223dce90e1f89f357cabdc16e234467cc2534e4554c804004b8457db52af71228726b170fa7c897352eec906e9a948ef327182725f01192a1a40d95940e2c70ed12f223dce90e1f89f357cabdc16e234467cc2534e4554c804004b8457db52af71228726b170fa7c897352eec906e9a948ef327182725f01192a"; const TX_RAW_MULTISIG_1_WASM_MSG: &str = "0afe010afb010a2e2f7365637265742e636f6d707574652e763162657461312e4d7367496e7374616e7469617465436f6e747261637412c8010a146ec8bb5da9e88846080909c92e17a4ffb5a26d3d1801221164656d6f20636f6e7472616374203020302a9a01e59282e2ba371e6a2e5010143b457a0af2abfa1e841b07f564c46dd0a059821ea84badd295af30098a70c150f5a8fcdd2c064f9c4496819a901128d7fa39851c19973806608a55cb38975ef40e9759f99a4f19936b0ed03217fea6a5d04fa3c6ce3e5723e26419f8abdabcb5de5bcbec1cb07506a3251cc33116f76f1feda7aee211388b01d755749d066e535daa4c56744809a945b766feaa90128f010a8a010a770a292f636f736d6f732e63727970746f2e6d756c74697369672e4c6567616379416d696e6f5075624b6579124a080112460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21030c8fd4f611563ded659dba55c334088ec75bbedf55b59becc93b6fb00650fe97120f120d0a05080112018012040a02087f12001a420a40c151aa0983ceaf6eea9fb634d0d05a79b23ff1fae11186de6782a768d466421534fbf572d086065819b77d59f81370dd343bac676aec3920244c7d5292be452d"; + const TX_RAW_REGISTRATION_MSG: &str = "0abb1d0ab81d0a2b2f7365637265742e726567697374726174696f6e2e763162657461312e526141757468656e74696361746512881d0a14ad4510fb2c8a82b7aba9d349b5bbaaaeda38879e12ef1c30820e6b30820e12a003020102020101300a06082a8648ce3d04030230143112301006035504030c09536563726574544545301e170d3233303532313133333332305a170d3333303532303133333332305a302a3128302606035504030c1f536563726574204e6574776f726b204e6f64652043657274696669636174653059301306072a8648ce3d020106082a8648ce3d03010703420004ced2fb7eeacd87cb5afec5013a8a81ae317d99c597472193b6a6b39b49bb6bbb7f43c4f3676eff59c1b7c8cc48d394eac9724057b3e565ec1dc0072bbe7a02f8a3820d3d30820d3930820d3506096086480186f842010d04820d267b227265706f7274223a2265794a705a434936496a45324d6a517a4d6a67774f5445334e7a55304d7a45314e6a67344d4445344e5445324e4459774d4467794e44597a4f4467794d794973496e52706257567a6447467463434936496a49774d6a4d744d4455744d6a46554d544d364d7a4d364d6a41754d6a677a4d444d3349697769646d567963326c76626949364e4377695a5842705a46427a5a58566b6232353562534936496d74426169744e63316836626d4d3561334e765357787a5956685a4b325a6c62315a4e556d746c5a555a755a4339684e4452434d5374744d3268715443737a5a53743562466c6b56464d7a51793944637a4e4357475268556e4a5a5744647a6333497855474d72516d4d3056564a714f4774736369746e654764574e336c534e46687a6369395951575a724d465a544e433831626a466f56455a334d6b746b615756435333687856335a5857564e6d6233565857584676616a67786431567655315234616d64715445526963477871634570324c304a726230746e576d74364d7a67324d4430694c434a685a485a70633239796556565354434936496d68306448427a4f6938766332566a64584a7064486b7459325675644756794c6d6c75644756734c6d4e7662534973496d466b646d6c7a62334a355355527a496a7062496b6c4f5645564d4c564e424c5441774d7a4d30496977695355355552557774553045744d4441324d5455695853776961584e325257356a624746325a5646316233526c553352686448567a496a6f6955316466534546535245564f53553548583035465255524652434973496d6c7a646b567559327868646d5652645739305a554a765a486b694f694a425a3046435155564254554642515539425154524251554642515546495a7a686b5a6a424653476c7064573930646b3554523059785a433830515546425155464251554642515546425155464251554642515546425258684e513049764b30464364304642515546425155464251554642515546425155464251554642515546425155464251554642515546425155464251554642515546425155464251554642515546425155464251554a52515546425155464251554642534546425155464251554642515570505257314565454e6a5747564f4e305272616c463363304935516d593556554d305a57744c4c33466d62305978575864594d54564f576b5a42515546425155464251554642515546425155464251554642515546425155464251554642515546425155464251554642515546425155464452566851546b6c4755464a5762474e6a5a7974434f54426c5654453056315247535651775555597864565645596e5a70534555764f4339775a304642515546425155464251554642515546425155464251554642515546425155464251554642515546425155464251554642515546425155464251554642515546425155464251554642515546425155464251554642515546425155464251554642515546425155464251554642515546425155464251554642515546425155464251554642515546425155464251554642515546425155464251554642515546425155464251554642515546425a304642515546425155464251554642515546425155464251554642515546425155464251554642515546425155464251554642515546425155464251554642515546425155464251554642515546425155464251554642515546425155464251554642515546425155464252474a3653444d335654524c656c5269626e52485a584578597a5a35556d35784e32355057564651623163315158646c4f455a474e446c5657476442515546425155464251554642515546425155464251554642515546425155464251554642515546425155464251554642515546425155456966513d3d222c227369676e6174757265223a22446b62314d73676f384259536b485051466e534d594a79394b554e2f44796c4e506448445734343736425868346d4c374c682b647638434664726f534b77383736455461784268552f4f702b7853552b6e78356d77434b524a463054497354434575716f734d4e556d4e50755545315241485578484c4f424239435567776447716a55727171384d49652b43642b6d727671594a6c6d397a475159706c357358795a6f6b4a6e4e35615246377a6d576a7842376e51545447313478424a332b2f4d313366596277314e4d6d686d375a424471674371774331743676313850705555582b67354d436434786a66714f2b30644c7970744e4649497349584544653358596866494c4b6b326c5230776f6b344933554861796b63434c5166704568306f316d324c6456484730484457656f79637a305959384b6c4775716a557553475378527a736d554f5843682b6c3151753266736e48513d3d222c227369676e696e675f63657274223a224d4949456f54434341776d67417749424167494a414e4548646c30796f3743574d413047435371475349623344514542437755414d483478437a414a42674e5642415954416c56544d517377435159445651514944414a44515445554d424947413155454277774c553246756447456751327868636d4578476a415942674e5642416f4d45556c756447567349454e76636e4276636d4630615739754d5441774c675944565151444443644a626e526c6243425452316767515852305a584e305958527062323467556d567762334a3049464e705a323570626d6367513045774868634e4d5459784d5449794d446b7a4e6a55345768634e4d6a59784d5449774d446b7a4e6a5534576a42374d517377435159445651514745774a56557a454c4d416b474131554543417743513045784644415342674e564241634d43314e68626e526849454e7359584a684d526f77474159445651514b4442464a626e526c6243424462334a7762334a6864476c76626a45744d437347413155454177776b535735305a57776755306459494546306447567a644746306157397549464a6c6347397964434254615764756157356e4d494942496a414e42676b71686b6947397730424151454641414f43415138414d49494243674b434151454171586f74344f5a75706852386e75644672414669614778786b676d612f45732f42412b74626543545552313036414c31454e635741344658334b2b453942424c302f375835726a356e4967582f522f317562686b4b5777396766715047334b654174496463762f75544f3179587635307671615076453143524368767a64532f5a45427151356f56764c54505a3356456963516a6c79744b674e39634c6e7862777475764c554b3765795250664a572f6b7364644f7a50385642426e696f6c596e524344326a724d525a386e424d325a5759776e586e7759654f4148562b5739744f6841496d7752774b462f393579417356776432317279484d4a426347483730714c61675a37547479742b2b714f2f362b4b41584a754b775a716a526c457453457a38675a51654666565967637753666f39366f534d417a56723756304c364853444c526e70623678786d625064714e6f6c3474514944415141426f34476b4d4947684d42384741315564497751594d426141464868446533616d66727a51723335434e2b733166447548415645384d41344741315564447745422f775145417749477744414d42674e5648524d4241663845416a41414d474147413155644877525a4d466377566142546f46474754326830644841364c793930636e567a6447566b63325679646d6c6a5a584d75615735305a577775593239744c324e76626e526c626e517651314a4d4c314e48574339426448526c6333526864476c76626c4a6c6347397964464e705a323570626d64445153356a636d77774451594a4b6f5a496876634e4151454c425141446767474241476349746874634b394956527a347252712b5a4b452b376b35302f4f7855736d57386161764f7a4b62306943783037595139727a69356e553733744d45327947524c7a6853566946732f4c704661396c70514c364a4c316151776d4452373454785947424149693566344935544a6f4343457152487a39316b7047365576796e32744c6d6e49644a62504534765976574c72745858664642535350443441666e372b332f58556767416c63376f4354697a4f666262744f466c59413467354b63596753314a325a41654d51716255645a73655a4363615a5a5a6e363574647165653855585a6c447678302b4e644f304c522b357046792b6a754d307757627535394d767a636d5458626a7369374859367a6435335971354b32343466774648525138654f42304957422b3450664d3746654141705a766c66716c4b4f6c4c635a4c327579566d7a526b79523579573732756f396d65685834344369504a32667365395936655174636645684d506b6d4858493031734e2b4b775062704133392b784f7353746a6850394e3159316132745141566f2b7956674c67563248777337334663306f3377433738715045412b76326152732f4265335a46446744796768632f316667552b37432b50366b62716434706f7962364957384b434a6278664d4a766b6f72644e4f674f5555786e64504845692f74622f5537754c6a4c4f6750413d3d227d300a06082a8648ce3d040302034700304402206734f4d44f9a6cd347db2c1373ba3035d3d31fa21a50ffd9dba22dce7007f33302202aaf8178c59de8fb89cfc1574ffbd264f7b356f1628c92e5a719994fb19aeffc12690a510a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2102511ff07856e34e3716efe44526db0259da8b73841d2ae41030f340c477fc254e12040a02080118a70e12140a0e0a0575736372741205333735303010f093091a40690bf055b9faa32ecefefc34ee4f22bd9a4519b5aec35d5160fc5e2584dfa8c815ebd5c9974780c14640fb274077e04840fd81cc847f7a0ecf8a4a6cae8988c5"; + pub fn parse_tx_basic() { let tx_bytes_hex = TX_RAW_SINGLE_WASM_MSG; @@ -124,6 +134,49 @@ pub mod tests { assert_eq!(super::message_is_wasm(&msg), true) } + pub fn check_message_is_reg() { + let tx_bytes_hex = TX_RAW_REGISTRATION_MSG; + + let tx_bytes = hex::decode(tx_bytes_hex).unwrap(); + + let tx = protoTx::tx::Tx::parse_from_bytes(tx_bytes.as_slice()).unwrap(); + + let msg = tx.body.unwrap().messages[0].clone(); + assert_eq!(super::message_is_reg(&msg), true) + } + + pub fn check_parse_reg_bytes() { + let tx_bytes_hex = TX_RAW_REGISTRATION_MSG; + + let tx_bytes = hex::decode(tx_bytes_hex).unwrap(); + + let tx = cosmos_proto::registration::v1beta1::msg::RaAuthenticate::parse_from_bytes( + tx_bytes.as_slice(), + ); + + assert!(tx.is_ok()); + } + + pub fn check_parse_reg_from_tx() { + let tx_bytes_hex = TX_RAW_REGISTRATION_MSG; + + const EXPECTED_CERTIFICATE: &str = "MIIOazCCDhKgAwIBAgIBATAKBggqhkjOPQQDAjAUM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hOWxwUUw2SkwxYVF3bURSNzRUeFlHQkFJaTVmNEk1VEpvQ0NFcVJIejkxa3BHNlV2eW4ydExtbklkSmJQRTR2WXZXTHJ0WFhmRkJTU1BENEFmbjcrMy9YVWdnQWxjN29DVGl6T2ZiYnRPRmxZQTRnNUtjWWdTMUoyWkFlTVFxYlVkWnNlWkNjYVpaWm42NXRkcWVlOFVYWmxEdngwK05kTzBMUis1cEZ5K2p1TTB3V2J1NTlNdnpjbVRYYmpzaTdIWTZ6ZDUzWXE1SzI0NGZ3RkhSUThlT0IwSVdCKzRQZk03RmVBQXBadmxmcWxLT2xMY1pMMnV5Vm16Umt5UjV5VzcydW85bWVoWDQ0Q2lQSjJmc2U5WTZlUXRjZkVoTVBrbUhYSTAxc04rS3dQYnBBMzkreE9zU3RqaFA5TjFZMWEydFFBVm8reVZnTGdWMkh3czczRmMwbzN3Qzc4cVBFQSt2MmFScy9CZTNaRkRnRHlnaGMvMWZnVSs3QytQNmticWQ0cG95YjZJVzhLQ0pieGZNSnZrb3JkTk9nT1VVeG5kUEhFaS90Yi9VN3VMakxPZ1BBPT0ifTAKBggqhkjOPQQDAgNHADBEAiBnNPTUT5ps00fbLBNzujA109MfohpQ/9nboi3OcAfzMwIgKq+BeMWd6PuJz8FXT/vSZPezVvFijJLlpxmZT7Ga7/w="; + + let cert_decoded = base64::decode(&EXPECTED_CERTIFICATE).unwrap(); + + let tx_bytes = hex::decode(tx_bytes_hex).unwrap(); + + let tx = protoTx::tx::Tx::parse_from_bytes(tx_bytes.as_slice()).unwrap(); + + let msg = tx.body.unwrap().messages[0].clone(); + + let tx = + cosmos_proto::registration::v1beta1::msg::RaAuthenticate::parse_from_bytes(&msg.value) + .unwrap(); + + assert_eq!(tx.certificate, cert_decoded) + } + pub fn parse_tx_multisig() { let tx_bytes_hex = TX_RAW_MULTISIG_1_WASM_MSG; @@ -150,7 +203,7 @@ pub mod tests { super::VERIFIED_MESSAGES .lock() .unwrap() - .append_wasm_from_tx(tx); + .append_msg_from_tx(tx); assert_eq!( super::VERIFIED_MESSAGES.lock().unwrap().remaining(), @@ -178,7 +231,7 @@ pub mod tests { super::VERIFIED_MESSAGES .lock() .unwrap() - .append_wasm_from_tx(tx); + .append_msg_from_tx(tx); assert_eq!( super::VERIFIED_MESSAGES.lock().unwrap().remaining(), diff --git a/cosmwasm/enclaves/shared/cosmos-proto/build.rs b/cosmwasm/enclaves/shared/cosmos-proto/build.rs index 7cbfa2287..5f6000ebb 100644 --- a/cosmwasm/enclaves/shared/cosmos-proto/build.rs +++ b/cosmwasm/enclaves/shared/cosmos-proto/build.rs @@ -47,6 +47,14 @@ mod protobuf { .expect(&format!("could not canonicalize {:?}", path)) } + fn from_reg(path: &str) -> PathBuf { + let mut full_path = PathBuf::from("../../../../proto/secret/registration"); + full_path.push(path); + full_path + .canonicalize() + .expect(&format!("could not canonicalize {:?}", path)) + } + pub fn build_protobuf_parsers() { let protoc_err_msg = "protoc failed to generate protobuf parsers"; let mut library_dir = dirs::home_dir().unwrap(); @@ -61,6 +69,10 @@ mod protobuf { from_cosmos("crypto/multisig/v1beta1/multisig.proto"), ], ), + ( + "src/registration/v1beta1/", + &[from_reg("v1beta1/msg.proto")], + ), ( "src/crypto/secp256k1", &[from_cosmos("crypto/secp256k1/keys.proto")], diff --git a/cosmwasm/enclaves/shared/cosmos-proto/src/lib.rs b/cosmwasm/enclaves/shared/cosmos-proto/src/lib.rs index 9585a20ca..e7f0d8f43 100644 --- a/cosmwasm/enclaves/shared/cosmos-proto/src/lib.rs +++ b/cosmwasm/enclaves/shared/cosmos-proto/src/lib.rs @@ -41,3 +41,9 @@ pub mod cosmwasm { use super::base::coin; } + +pub mod registration { + pub mod v1beta1 { + pub mod msg; + } +} diff --git a/cosmwasm/enclaves/shared/cosmos-proto/src/registration/v1beta1/msg.rs b/cosmwasm/enclaves/shared/cosmos-proto/src/registration/v1beta1/msg.rs new file mode 100644 index 000000000..bb2b9b7fd --- /dev/null +++ b/cosmwasm/enclaves/shared/cosmos-proto/src/registration/v1beta1/msg.rs @@ -0,0 +1,568 @@ +// This file is generated by rust-protobuf 2.25.2. Do not edit +// @generated + +// https://github.com/rust-lang/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy::all)] + +#![allow(unused_attributes)] +#![cfg_attr(rustfmt, rustfmt::skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unused_imports)] +#![allow(unused_results)] +//! Generated file from `secret/registration/v1beta1/msg.proto` + +/// Generated files are compatible only with the same version +/// of protobuf runtime. +// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_2; + +#[derive(PartialEq,Clone,Default)] +pub struct RaAuthenticate { + // message fields + pub sender: ::std::vec::Vec, + pub certificate: ::std::vec::Vec, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a RaAuthenticate { + fn default() -> &'a RaAuthenticate { + ::default_instance() + } +} + +impl RaAuthenticate { + pub fn new() -> RaAuthenticate { + ::std::default::Default::default() + } + + // bytes sender = 1; + + + pub fn get_sender(&self) -> &[u8] { + &self.sender + } + pub fn clear_sender(&mut self) { + self.sender.clear(); + } + + // Param is passed by value, moved + pub fn set_sender(&mut self, v: ::std::vec::Vec) { + self.sender = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_sender(&mut self) -> &mut ::std::vec::Vec { + &mut self.sender + } + + // Take field + pub fn take_sender(&mut self) -> ::std::vec::Vec { + ::std::mem::replace(&mut self.sender, ::std::vec::Vec::new()) + } + + // bytes certificate = 2; + + + pub fn get_certificate(&self) -> &[u8] { + &self.certificate + } + pub fn clear_certificate(&mut self) { + self.certificate.clear(); + } + + // Param is passed by value, moved + pub fn set_certificate(&mut self, v: ::std::vec::Vec) { + self.certificate = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_certificate(&mut self) -> &mut ::std::vec::Vec { + &mut self.certificate + } + + // Take field + pub fn take_certificate(&mut self) -> ::std::vec::Vec { + ::std::mem::replace(&mut self.certificate, ::std::vec::Vec::new()) + } +} + +impl ::protobuf::Message for RaAuthenticate { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_bytes_into(wire_type, is, &mut self.sender)?; + }, + 2 => { + ::protobuf::rt::read_singular_proto3_bytes_into(wire_type, is, &mut self.certificate)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.sender.is_empty() { + my_size += ::protobuf::rt::bytes_size(1, &self.sender); + } + if !self.certificate.is_empty() { + my_size += ::protobuf::rt::bytes_size(2, &self.certificate); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + if !self.sender.is_empty() { + os.write_bytes(1, &self.sender)?; + } + if !self.certificate.is_empty() { + os.write_bytes(2, &self.certificate)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> RaAuthenticate { + RaAuthenticate::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBytes>( + "sender", + |m: &RaAuthenticate| { &m.sender }, + |m: &mut RaAuthenticate| { &mut m.sender }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBytes>( + "certificate", + |m: &RaAuthenticate| { &m.certificate }, + |m: &mut RaAuthenticate| { &mut m.certificate }, + )); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "RaAuthenticate", + fields, + file_descriptor_proto() + ) + }) + } + + fn default_instance() -> &'static RaAuthenticate { + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(RaAuthenticate::new) + } +} + +impl ::protobuf::Clear for RaAuthenticate { + fn clear(&mut self) { + self.sender.clear(); + self.certificate.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for RaAuthenticate { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for RaAuthenticate { + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct MasterKey { + // message fields + pub bytes: ::std::vec::Vec, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a MasterKey { + fn default() -> &'a MasterKey { + ::default_instance() + } +} + +impl MasterKey { + pub fn new() -> MasterKey { + ::std::default::Default::default() + } + + // bytes bytes = 1; + + + pub fn get_bytes(&self) -> &[u8] { + &self.bytes + } + pub fn clear_bytes(&mut self) { + self.bytes.clear(); + } + + // Param is passed by value, moved + pub fn set_bytes(&mut self, v: ::std::vec::Vec) { + self.bytes = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_bytes(&mut self) -> &mut ::std::vec::Vec { + &mut self.bytes + } + + // Take field + pub fn take_bytes(&mut self) -> ::std::vec::Vec { + ::std::mem::replace(&mut self.bytes, ::std::vec::Vec::new()) + } +} + +impl ::protobuf::Message for MasterKey { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_bytes_into(wire_type, is, &mut self.bytes)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.bytes.is_empty() { + my_size += ::protobuf::rt::bytes_size(1, &self.bytes); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + if !self.bytes.is_empty() { + os.write_bytes(1, &self.bytes)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> MasterKey { + MasterKey::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBytes>( + "bytes", + |m: &MasterKey| { &m.bytes }, + |m: &mut MasterKey| { &mut m.bytes }, + )); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "MasterKey", + fields, + file_descriptor_proto() + ) + }) + } + + fn default_instance() -> &'static MasterKey { + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(MasterKey::new) + } +} + +impl ::protobuf::Clear for MasterKey { + fn clear(&mut self) { + self.bytes.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for MasterKey { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MasterKey { + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Key { + // message fields + pub key: ::std::vec::Vec, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Key { + fn default() -> &'a Key { + ::default_instance() + } +} + +impl Key { + pub fn new() -> Key { + ::std::default::Default::default() + } + + // bytes key = 1; + + + pub fn get_key(&self) -> &[u8] { + &self.key + } + pub fn clear_key(&mut self) { + self.key.clear(); + } + + // Param is passed by value, moved + pub fn set_key(&mut self, v: ::std::vec::Vec) { + self.key = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_key(&mut self) -> &mut ::std::vec::Vec { + &mut self.key + } + + // Take field + pub fn take_key(&mut self) -> ::std::vec::Vec { + ::std::mem::replace(&mut self.key, ::std::vec::Vec::new()) + } +} + +impl ::protobuf::Message for Key { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_bytes_into(wire_type, is, &mut self.key)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.key.is_empty() { + my_size += ::protobuf::rt::bytes_size(1, &self.key); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + if !self.key.is_empty() { + os.write_bytes(1, &self.key)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Key { + Key::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBytes>( + "key", + |m: &Key| { &m.key }, + |m: &mut Key| { &mut m.key }, + )); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "Key", + fields, + file_descriptor_proto() + ) + }) + } + + fn default_instance() -> &'static Key { + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(Key::new) + } +} + +impl ::protobuf::Clear for Key { + fn clear(&mut self) { + self.key.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Key { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Key { + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) + } +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n%secret/registration/v1beta1/msg.proto\x12\x1bsecret.registration.v1be\ + ta1\x1a\x14gogoproto/gogo.proto\"\xde\x01\n\x0eRaAuthenticate\x12I\n\x06\ + sender\x18\x01\x20\x01(\x0cR\x06senderB1\xfa\xde\x1f-github.aaakk.us.kg/cosmos/c\ + osmos-sdk/types.AccAddress\x12\x80\x01\n\x0bcertificate\x18\x02\x20\x01(\ + \x0cR\x0bcertificateB^\xfa\xde\x1fOgithub.com/scrtlabs/SecretNetwork/x/r\ + egistration/remote_attestation.Certificate\xea\xde\x1f\x07ra_cert\"!\n\t\ + MasterKey\x12\x14\n\x05bytes\x18\x01\x20\x01(\x0cR\x05bytes\"\x20\n\x03K\ + ey\x12\x19\n\x03key\x18\x01\x20\x01(\x0cR\x03keyB\x07\xea\xde\x1f\x03key\ + BIZ?github.com/scrtlabs/SecretNetwork/x/registration/internal/types\xc8\ + \xe1\x1e\0\xa8\xe2\x1e\x01b\x06proto3\ +"; + +static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; + +fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { + ::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap() +} + +pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + file_descriptor_proto_lazy.get(|| { + parse_descriptor_proto() + }) +} diff --git a/x/registration/internal/keeper/keeper.go b/x/registration/internal/keeper/keeper.go index adef6762a..87c229875 100644 --- a/x/registration/internal/keeper/keeper.go +++ b/x/registration/internal/keeper/keeper.go @@ -210,6 +210,7 @@ func (k Keeper) RegisterNode(ctx sdk.Context, certificate ra.Certificate) ([]byt if isAuth { return k.getRegistrationInfo(ctx, publicKey).EncryptedSeed, nil } + encSeed, err = k.enclave.GetEncryptedSeed(certificate) if err != nil { // return 0, sdkerrors.Wrap(err, "cosmwasm create")