From 8f6e8a01c1b706d88df905971bdf63df1fad2530 Mon Sep 17 00:00:00 2001 From: xlassix Date: Wed, 12 Feb 2025 10:21:13 +0100 Subject: [PATCH 1/4] Add batch verification for proof requests --- ic/libraries/src/verify/types.rs | 2 +- ic/managed/verifier/src/lib.rs | 22 +++++++++++++-- ic/managed/verifier/src/proof.rs | 46 +++++++++++++++++++++++++++----- 3 files changed, 60 insertions(+), 10 deletions(-) diff --git a/ic/libraries/src/verify/types.rs b/ic/libraries/src/verify/types.rs index f5015b078a..cf11432ad2 100644 --- a/ic/libraries/src/verify/types.rs +++ b/ic/libraries/src/verify/types.rs @@ -74,7 +74,7 @@ impl ProofResponse { // Parse the response match parsed_response.parse(response_bytes) { - Ok(httparse::Status::Complete(header_length)) => { + Ok(httparse::Status::Complete(_header_length)) => { let mut result = HashMap::new(); // Insert status code diff --git a/ic/managed/verifier/src/lib.rs b/ic/managed/verifier/src/lib.rs index ff348319ea..7a14080a9b 100644 --- a/ic/managed/verifier/src/lib.rs +++ b/ic/managed/verifier/src/lib.rs @@ -1,7 +1,7 @@ use crate::state::CONFIG; use candid::Principal; use ic_cdk::storage; -use proof::{ verify_and_sign_proof_requests, verify_proof_requests, DirectVerificationResponse }; +use proof::{ verify_and_sign_proof_requests, verify_proof_requests, verify_proof_requests_batch, verify_and_sign_proof_requests_batch, DirectVerificationResponse }; use utils::init_canister; use verity_ic::{ crypto::{ @@ -36,10 +36,19 @@ async fn verify_proof_async( notary_pub_key: String ) -> Vec { let verification_response = verify_proof_requests(proof_requests, notary_pub_key); - verification_response } +/// Asynchronously verifies batch proof requests; intended for canister calls +#[ic_cdk::update] +async fn verify_proof_async_batch( + batches: Vec<(Vec, String)> +) ->Vec { + let verification_responses = verify_proof_requests_batch(batches); + verification_responses + +} + /// Asynchronously verifies proof requests; intended for direct user calls /// Returns a detailed verification response #[ic_cdk::update] @@ -50,6 +59,15 @@ async fn verify_proof_direct( verify_and_sign_proof_requests(proof_requests, notary_pub_key).await } +/// Asynchronously verifies proof requests; intended for direct user calls +/// Returns a detailed verification response +#[ic_cdk::update] +async fn verify_proof_direct_batch( + batches: Vec<(Vec, String)> +) -> Result { + verify_and_sign_proof_requests_batch(batches).await +} + /// Retrieves the public key of the canister #[ic_cdk::update] async fn public_key() -> PublicKeyReply { diff --git a/ic/managed/verifier/src/proof.rs b/ic/managed/verifier/src/proof.rs index c5b6d23e6a..9692d80cd8 100644 --- a/ic/managed/verifier/src/proof.rs +++ b/ic/managed/verifier/src/proof.rs @@ -88,14 +88,25 @@ pub fn verify_proof_requests( proof_responses } -pub async fn verify_and_sign_proof_requests( - proof_requests: Vec, - notary_pub_key: String -) -> Result { - // iterate through the proofs and try verifying them - let proof_responses: Vec = verify_proof_requests(proof_requests, notary_pub_key); +pub fn verify_proof_requests_batch( + batches: Vec<(Vec, String)> +) -> Vec { + batches.into_iter().flat_map(|(proof_requests, notary_pub_key)| { + // Unescape the public key. + let notary_pub_key = notary_pub_key.replace("\\n", "\n"); + + // Process each proof request in this batch. + proof_requests.into_iter().map(|proof_str| { + let proof_request: ProofRequest = proof_str.try_into().unwrap(); + proof_request.verify_request(¬ary_pub_key).unwrap() + }).collect::>() + }).collect() +} - // generate a merkle tree based on the content of the proof responses as leaves +async fn process_and_sign( + proof_responses: Vec +)->Result{ + // generate a merkle tree based on the content of the proof responses as leaves let merkle_tree = generate_merkle_tree(&proof_responses); let merkle_root = merkle_tree.root().expect("NOT ENOUGH LEAVES"); let merkle_root = hex::encode(merkle_root); @@ -112,3 +123,24 @@ pub async fn verify_and_sign_proof_requests( signature, }) } + +pub async fn verify_and_sign_proof_requests( + proof_requests: Vec, + notary_pub_key: String +) -> Result { + // iterate through the proofs and try verifying them + let proof_responses: Vec = verify_proof_requests(proof_requests, notary_pub_key); + + return process_and_sign(proof_responses).await; +} + + + +pub async fn verify_and_sign_proof_requests_batch( + batches :Vec<( Vec, String)> +) -> Result { + // iterate through the proofs and try verifying them + let proof_responses: Vec = verify_proof_requests_batch(batches); + + return process_and_sign(proof_responses).await; +} \ No newline at end of file From cbfe451ea972c1de9f7a4aa8744e3928ebbbbbd7 Mon Sep 17 00:00:00 2001 From: xlassix Date: Wed, 12 Feb 2025 11:07:41 +0100 Subject: [PATCH 2/4] Add batch verification to verity_verifier service --- ic/managed/verifier/verity_verifier.did | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ic/managed/verifier/verity_verifier.did b/ic/managed/verifier/verity_verifier.did index 57915ae77d..f2b05f5a2c 100644 --- a/ic/managed/verifier/verity_verifier.did +++ b/ic/managed/verifier/verity_verifier.did @@ -22,10 +22,18 @@ type DirectVerificationResult = variant { Err : text; }; +type ProofBatch = record { + proof_requests : vec text; + notary_pub_key : text; +}; + service : { "ping" : () -> (text) query; "verify_proof_direct" : (proof_requests : vec text, notary_pub_key : text) -> (DirectVerificationResult); "verify_proof_async" : (proof_requests : vec text, notary_pub_key : text) -> (ProofVerificationResponse); + "verify_proof_direct_batch": (batches: vec ProofBatch) -> (DirectVerificationResult); + "verify_proof_async_batch" : (batches: vec ProofBatch) -> (ProofVerificationResponse); "public_key" : () -> (record { sec1_pk : text; etherum_pk : text }); }; +l \ No newline at end of file From ffb2a268d6f80094ba0e48b645a578ad3f25fd1d Mon Sep 17 00:00:00 2001 From: xlassix Date: Wed, 12 Feb 2025 12:36:08 +0100 Subject: [PATCH 3/4] Refactor batch verification to use ProofBatch struct --- ic/managed/verifier/src/lib.rs | 12 ++++++--- ic/managed/verifier/src/proof.rs | 34 +++++++++++++++---------- ic/managed/verifier/verity_verifier.did | 9 +++---- rs/verify-tls/src/session.rs | 4 +-- 4 files changed, 35 insertions(+), 24 deletions(-) diff --git a/ic/managed/verifier/src/lib.rs b/ic/managed/verifier/src/lib.rs index 7a14080a9b..39d87da07f 100644 --- a/ic/managed/verifier/src/lib.rs +++ b/ic/managed/verifier/src/lib.rs @@ -1,7 +1,13 @@ use crate::state::CONFIG; use candid::Principal; use ic_cdk::storage; -use proof::{ verify_and_sign_proof_requests, verify_proof_requests, verify_proof_requests_batch, verify_and_sign_proof_requests_batch, DirectVerificationResponse }; +use proof::{ + verify_and_sign_proof_requests, + verify_proof_requests, + verify_proof_requests_batch, + verify_and_sign_proof_requests_batch, + ProofBatch, + DirectVerificationResponse }; use utils::init_canister; use verity_ic::{ crypto::{ @@ -42,7 +48,7 @@ async fn verify_proof_async( /// Asynchronously verifies batch proof requests; intended for canister calls #[ic_cdk::update] async fn verify_proof_async_batch( - batches: Vec<(Vec, String)> + batches: Vec ) ->Vec { let verification_responses = verify_proof_requests_batch(batches); verification_responses @@ -63,7 +69,7 @@ async fn verify_proof_direct( /// Returns a detailed verification response #[ic_cdk::update] async fn verify_proof_direct_batch( - batches: Vec<(Vec, String)> + batches: Vec ) -> Result { verify_and_sign_proof_requests_batch(batches).await } diff --git a/ic/managed/verifier/src/proof.rs b/ic/managed/verifier/src/proof.rs index 9692d80cd8..ccbd250f2d 100644 --- a/ic/managed/verifier/src/proof.rs +++ b/ic/managed/verifier/src/proof.rs @@ -17,6 +17,12 @@ pub struct DirectVerificationResponse { pub signature: String, } +#[derive(CandidType, Deserialize)] +pub struct ProofBatch { + pub proof_requests: Vec, + pub notary_pub_key: String, +} + #[derive(CandidType, Deserialize, Debug, Clone)] pub enum ProofRequest { SessionProof(String), @@ -88,20 +94,20 @@ pub fn verify_proof_requests( proof_responses } -pub fn verify_proof_requests_batch( - batches: Vec<(Vec, String)> -) -> Vec { - batches.into_iter().flat_map(|(proof_requests, notary_pub_key)| { - // Unescape the public key. - let notary_pub_key = notary_pub_key.replace("\\n", "\n"); - - // Process each proof request in this batch. - proof_requests.into_iter().map(|proof_str| { - let proof_request: ProofRequest = proof_str.try_into().unwrap(); - proof_request.verify_request(¬ary_pub_key).unwrap() - }).collect::>() - }).collect() + +pub fn verify_proof_requests_batch(batches: Vec) -> Vec { + batches.into_iter().flat_map(|batch| { + // Unescape special characters in the public key. + let notary_pub_key = batch.notary_pub_key.replace("\\n", "\n"); + + // Process each proof request in this batch. + batch.proof_requests.into_iter().map(|proof_str| { + let proof_request: ProofRequest = proof_str.try_into().unwrap(); + proof_request.verify_request(¬ary_pub_key).unwrap() + }).collect::>() + }).collect() } + async fn process_and_sign( proof_responses: Vec @@ -137,7 +143,7 @@ pub async fn verify_and_sign_proof_requests( pub async fn verify_and_sign_proof_requests_batch( - batches :Vec<( Vec, String)> + batches :Vec ) -> Result { // iterate through the proofs and try verifying them let proof_responses: Vec = verify_proof_requests_batch(batches); diff --git a/ic/managed/verifier/verity_verifier.did b/ic/managed/verifier/verity_verifier.did index f2b05f5a2c..04d1625622 100644 --- a/ic/managed/verifier/verity_verifier.did +++ b/ic/managed/verifier/verity_verifier.did @@ -32,8 +32,7 @@ service : { "ping" : () -> (text) query; "verify_proof_direct" : (proof_requests : vec text, notary_pub_key : text) -> (DirectVerificationResult); "verify_proof_async" : (proof_requests : vec text, notary_pub_key : text) -> (ProofVerificationResponse); - "verify_proof_direct_batch": (batches: vec ProofBatch) -> (DirectVerificationResult); - "verify_proof_async_batch" : (batches: vec ProofBatch) -> (ProofVerificationResponse); - "public_key" : () -> (record { sec1_pk : text; etherum_pk : text }); -}; -l \ No newline at end of file + "verify_proof_direct_batch": (batches: vec ProofBatch) -> (DirectVerificationResult); + "verify_proof_async_batch" : (batches: vec ProofBatch) -> (ProofVerificationResponse); + "public_key" : () -> (record { sec1_pk : text; ethereum_pk : text }); +}; \ No newline at end of file diff --git a/rs/verify-tls/src/session.rs b/rs/verify-tls/src/session.rs index cc8afd6511..068e8ddaea 100644 --- a/rs/verify-tls/src/session.rs +++ b/rs/verify-tls/src/session.rs @@ -7,13 +7,13 @@ use elliptic_curve::pkcs8::DecodePublicKey; pub fn verify_session(proof: &String, pub_key: &String) -> Result<(), String> { let session: SessionProof = serde_json::from_str(proof.as_str()).or(Err("INVALID PROOF".to_owned()))?; - + let pub_key = p256::PublicKey::from_public_key_pem(pub_key.as_str()) .or(Err("INVALID PUBLIC KEY".to_owned()))?; session .verify_with_default_cert_verifier(pub_key) - .or(Err("INVALID PUBLIC KEY".to_owned())) + .or(Err("INVALID PROOF SESSION".to_owned())) } /// A simple verifier which reads a proof generated by `simple_prover.rs` from "proof.json", verifies From 2770724a440bc8d0b33c6c89fae9b47db253df8e Mon Sep 17 00:00:00 2001 From: Ryan Soury Date: Fri, 14 Feb 2025 12:55:50 +1100 Subject: [PATCH 4/4] format rs files in managed verifier --- .vscode/settings.json | 1 + Cargo.lock | 413 +++++++++++++++++------------- ic/managed/verifier/src/lib.rs | 109 ++++---- ic/managed/verifier/src/merkle.rs | 26 +- ic/managed/verifier/src/proof.rs | 211 +++++++-------- ic/managed/verifier/src/state.rs | 4 +- ic/managed/verifier/src/utils.rs | 43 ++-- 7 files changed, 439 insertions(+), 368 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index d06a0911c4..e9abc2d410 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,7 @@ { "rust-analyzer.linkedProjects": [ "ic/canisters/asset_manager/Cargo.toml", + "ic/managed/verifier/Cargo.toml", "examples/zktls/Cargo.toml", "zk/tests/zkvm/Cargo.toml", ] diff --git a/Cargo.lock b/Cargo.lock index 181e861b7d..e5fb04fa8e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -76,9 +76,9 @@ dependencies = [ [[package]] name = "alloy-chains" -version = "0.1.57" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ab9d1367c6ffb90c93fb4a9a4989530aa85112438c6f73a734067255d348469" +checksum = "3a754dbb534198644cb8355b8c23f4aaecf03670fb9409242be1fa1e25897ee9" dependencies = [ "alloy-primitives", "num_enum", @@ -123,9 +123,9 @@ dependencies = [ [[package]] name = "alloy-core" -version = "0.8.19" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "648275bb59110f88cc5fa9a176845e52a554ebfebac2d21220bcda8c9220f797" +checksum = "482f377cebceed4bb1fb5e7970f0805e2ab123d06701be9351b67ed6341e74aa" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -136,9 +136,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.8.19" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc9138f4f0912793642d453523c3116bd5d9e11de73b70177aa7cb3e94b98ad2" +checksum = "555896f0b8578adb522b1453b6e6cc6704c3027bd0af20058befdde992cee8e9" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -148,7 +148,7 @@ dependencies = [ "itoa", "serde", "serde_json", - "winnow 0.6.24", + "winnow 0.7.2", ] [[package]] @@ -204,9 +204,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.8.19" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24acd2f5ba97c7a320e67217274bc81fe3c3174b8e6144ec875d9d54e760e278" +checksum = "4012581681b186ba0882007ed873987cc37f86b1b488fe6b91d5efd0b585dc41" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -264,9 +264,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.19" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec878088ec6283ce1e90d280316aadd3d6ce3de06ff63d68953c855e7e447e92" +checksum = "478bedf4d24e71ea48428d1bc278553bd7c6ae07c30ca063beb0b09fe58a9e74" dependencies = [ "alloy-rlp", "bytes", @@ -342,7 +342,7 @@ checksum = "a40e1ef334153322fd878d07e86af7a529bcb86b2439525920a88eba87bcf943" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -413,23 +413,23 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.19" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d039d267aa5cbb7732fa6ce1fd9b5e9e29368f580f80ba9d7a8450c794de4b2" +checksum = "a2708e27f58d747423ae21d31b7a6625159bd8d867470ddd0256f396a68efa11" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] name = "alloy-sol-macro-expander" -version = "0.8.19" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "620ae5eee30ee7216a38027dec34e0585c55099f827f92f50d11e3d2d3a4a954" +checksum = "c6b7984d7e085dec382d2c5ef022b533fcdb1fe6129200af30ebf5afddb6a361" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -439,16 +439,16 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", "syn-solidity", "tiny-keccak", ] [[package]] name = "alloy-sol-macro-input" -version = "0.8.19" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad9f7d057e00f8c5994e4ff4492b76532c51ead39353aa2ed63f8c50c0f4d52e" +checksum = "33d6a9fc4ed1a3c70bdb2357bec3924551c1a59f24e5a04a74472c755b37f87d" dependencies = [ "alloy-json-abi", "const-hex", @@ -457,25 +457,25 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.96", + "syn 2.0.98", "syn-solidity", ] [[package]] name = "alloy-sol-type-parser" -version = "0.8.19" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74e60b084fe1aef8acecda2743ff2d93c18ff3eb67a2d3b12f62582a1e66ef5e" +checksum = "1b1b3e9a48a6dd7bb052a111c8d93b5afc7956ed5e2cb4177793dc63bb1d2a36" dependencies = [ "serde", - "winnow 0.6.24", + "winnow 0.7.2", ] [[package]] name = "alloy-sol-types" -version = "0.8.19" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1382302752cd751efd275f4d6ef65877ddf61e0e6f5ac84ef4302b79a33a31a" +checksum = "6044800da35c38118fd4b98e18306bd3b91af5dedeb54c1b768cf1b4fb68f549" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -806,18 +806,18 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] name = "async-trait" -version = "0.1.85" +version = "0.1.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f934833b4b7233644e5848f235df3f57ed8c80f1528a26c3dfa13d2147fa056" +checksum = "644dd749086bf3771a2fbc5f256fdb982d53f011c7d5d560304eafeecebce79d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -834,7 +834,7 @@ checksum = "e12882f59de5360c748c4cbf569a042d5fb0eb515f7bea9c1f470b47f6ffbd73" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -849,7 +849,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b62ddb9cb1ec0a098ad4bbf9344d0713fa193ae1a80af55febcff2627b6a00c1" dependencies = [ - "getrandom", + "getrandom 0.2.15", "instant", "rand", ] @@ -1077,9 +1077,9 @@ checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" [[package]] name = "blst" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4378725facc195f1a538864863f6de233b500a8862747e7f165078a419d5e874" +checksum = "47c79a94619fade3c0b887670333513a67ac28a6a7e653eb260bf0d4103db38d" dependencies = [ "cc", "glob", @@ -1107,7 +1107,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -1118,9 +1118,9 @@ checksum = "b4ae4235e6dac0694637c763029ecea1a2ec9e4e06ec2729bd21ba4d9c863eb7" [[package]] name = "bumpalo" -version = "3.16.0" +version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" [[package]] name = "byte-slice-cast" @@ -1151,7 +1151,7 @@ checksum = "3fa76293b4f7bb636ab88fd78228235b5248b4d05cc589aed610f954af5d7c7a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -1162,9 +1162,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" +checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9" dependencies = [ "serde", ] @@ -1238,7 +1238,7 @@ dependencies = [ "lazy_static", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -1266,9 +1266,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.10" +version = "1.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229" +checksum = "c7777341816418c02e033934a09f20dc0ccaf65a5201ef8a450ae0105a573fda" dependencies = [ "shlex", ] @@ -1360,6 +1360,26 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "const_format" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126f97965c8ad46d6d9163268ff28432e8f6a1196a55578867832e3049df63dd" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d57c2eccfb16dbac1f4e61e206105db5820c9d26c3c472bc17c774259ef7744" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + [[package]] name = "constant_time_eq" version = "0.3.1" @@ -1395,9 +1415,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" dependencies = [ "libc", ] @@ -1549,9 +1569,9 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.7.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e60eed09d8c01d3cee5b7d30acb059b76614c918fa0f992e0dd6eeb10daad6f" +checksum = "575f75dfd25738df5b91b8e43e14d44bda14637a58fae779fd2b064f8bf3e010" [[package]] name = "der" @@ -1632,7 +1652,7 @@ checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", "unicode-xid", ] @@ -1695,7 +1715,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -2019,7 +2039,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -2126,7 +2146,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -2200,10 +2220,22 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "wasm-bindgen", ] +[[package]] +name = "getrandom" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.13.3+wasi-0.2.2", + "windows-targets 0.52.6", +] + [[package]] name = "gimli" version = "0.31.1" @@ -2365,15 +2397,15 @@ dependencies = [ [[package]] name = "httparse" -version = "1.9.5" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" +checksum = "f2d708df4e7140240a16cd6ab0ab65c972d7433ab77819ea693fde9c43811e2a" [[package]] name = "hyper" -version = "1.5.2" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" +checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" dependencies = [ "bytes", "futures-channel", @@ -2533,7 +2565,7 @@ dependencies = [ "quote", "serde", "serde_tokenstream 0.2.2", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -2767,7 +2799,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -2812,7 +2844,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" dependencies = [ - "parity-scale-codec 3.6.12", + "parity-scale-codec 3.7.4", ] [[package]] @@ -2841,7 +2873,7 @@ checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -2897,6 +2929,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.14" @@ -2972,7 +3013,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -3166,9 +3207,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" +checksum = "b3b1c9bd4fe1f0f8b387f6eb9eb3b4a1aa26185e5750efb9140301703f62cd1b" dependencies = [ "adler2", ] @@ -3180,7 +3221,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.52.0", ] @@ -3259,9 +3300,9 @@ dependencies = [ [[package]] name = "native-tls" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +checksum = "0dab59f8e050d5df8e4dd87d9206fb6f65a483e20ac9fda365ade4fab353196c" dependencies = [ "libc", "log", @@ -3357,7 +3398,7 @@ checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -3380,9 +3421,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.2" +version = "1.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" [[package]] name = "opaque-debug" @@ -3398,9 +3439,9 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "openssl" -version = "0.10.68" +version = "0.10.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" +checksum = "61cfb4e166a8bb8c9b55c500bc2308550148ece889be90f609377e58140f42c6" dependencies = [ "bitflags 2.8.0", "cfg-if", @@ -3419,20 +3460,20 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] name = "openssl-probe" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" [[package]] name = "openssl-sys" -version = "0.9.104" +version = "0.9.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" +checksum = "8b22d5b84be05a8d6947c7cb71f7c849aa0f112acd4bf51c2a7c1c988ac0a9dc" dependencies = [ "cc", "libc", @@ -3490,15 +3531,17 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.6.12" +version = "3.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" +checksum = "c9fde3d0718baf5bc92f577d652001da0f8d54cd03a7974e118d04fc888dc23d" dependencies = [ "arrayvec 0.7.6", "bitvec 1.0.1", "byte-slice-cast", + "const_format", "impl-trait-for-tuples", - "parity-scale-codec-derive 3.6.12", + "parity-scale-codec-derive 3.7.4", + "rustversion", "serde", ] @@ -3516,14 +3559,14 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.12" +version = "3.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" +checksum = "581c837bb6b9541ce7faa9377c20616e4fb7650f6b0f68bc93c827ee504fb7b3" dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.98", ] [[package]] @@ -3599,22 +3642,22 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.8" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e2ec53ad785f4d35dac0adea7f7dc6f1bb277ad84a680c7afefeae05d1f5916" +checksum = "dfe2e71e1471fe07709406bf725f710b02927c9c54b2b5b2ec0e8087d97c327d" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.8" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56a66c0c55993aa927429d0f8a0abfd74f084e4d9c192cffed01e418d83eefb" +checksum = "f6e859e6e5bd50440ab63c47e3ebabc90f26251f7c73c3d3e837b74a1cc3fa67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -3721,7 +3764,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ - "toml_edit 0.22.22", + "toml_edit 0.22.24", ] [[package]] @@ -3743,7 +3786,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -3777,9 +3820,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.13.4" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c0fef6c4230e4ccf618a35c59d7ede15dea37de8427500f50aff708806e42ec" +checksum = "2796faa41db3ec313a31f7624d9286acf277b52de526150b7e69f3debf891ee5" dependencies = [ "bytes", "prost-derive", @@ -3787,15 +3830,15 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.13.4" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "157c5a9d7ea5c2ed2d9fb8f495b64759f7816c7eaea54ba3978f0d63000162e3" +checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" dependencies = [ "anyhow", - "itertools 0.13.0", + "itertools 0.14.0", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -3838,7 +3881,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2fe5ef3495d7d2e377ff17b1a8ce2ee2ec2a18cde8b6ad6619d65d0701c135d" dependencies = [ "bytes", - "getrandom", + "getrandom 0.2.15", "rand", "ring", "rustc-hash", @@ -3914,7 +3957,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.15", ] [[package]] @@ -3967,7 +4010,7 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ - "getrandom", + "getrandom 0.2.15", "libredox", "thiserror 1.0.69", ] @@ -4093,7 +4136,7 @@ checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if", - "getrandom", + "getrandom 0.2.15", "libc", "spin", "untrusted", @@ -4102,9 +4145,9 @@ dependencies = [ [[package]] name = "risc0-binfmt" -version = "1.2.1" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2d38498a55589122b195aa5024d2c0b02231efdb01c090881b9d535660f97c9" +checksum = "cc047ec0ec944104bf94cf55efa3a697aca63cff506cc949ec8d345c48ef0706" dependencies = [ "anyhow", "borsh", @@ -4117,9 +4160,9 @@ dependencies = [ [[package]] name = "risc0-build" -version = "1.2.1" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b178bec61b5a589feeddcc8f9987119dccfd32f17d98dfedf14921591b35bf4" +checksum = "2336678ab6701f737522f153050c8c688860a2db29ef8fea7a42ae0a1de614d6" dependencies = [ "anyhow", "cargo_metadata", @@ -4147,9 +4190,9 @@ dependencies = [ [[package]] name = "risc0-circuit-keccak" -version = "1.2.1" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "723af53138c76e5c167f52c0396071ebd735a79561732de974dabb545ba2d1be" +checksum = "2cc983c81ee51af9bde296eb1b4dff73501fb436c3401d30d5548e00b2c0a354" dependencies = [ "anyhow", "bytemuck", @@ -4163,9 +4206,9 @@ dependencies = [ [[package]] name = "risc0-circuit-recursion" -version = "1.2.1" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c7665d06d6dd42bff80dd7690fddecc49b664621336ad0542505e139a470ad" +checksum = "c7d68e1a5344eb83553a6a465fcec5ceb4ab751e7b3b96c46a6c03b697f70856" dependencies = [ "anyhow", "bytemuck", @@ -4178,9 +4221,9 @@ dependencies = [ [[package]] name = "risc0-circuit-rv32im" -version = "1.2.1" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53c44a97bf5f90a90a51fcc3667b12592a407431f7bab34dc5e77f097675699d" +checksum = "8ca07c57b1b0eff21288a7b193a06b2b5943b3eceda6dafa0c087cbe0fcfcfa6" dependencies = [ "anyhow", "metal", @@ -4194,9 +4237,9 @@ dependencies = [ [[package]] name = "risc0-core" -version = "1.2.1" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09f45bab0bb477240e7d45a25e618603ef4196421728a115b6d4b7a6036535a5" +checksum = "5a3ba5078ac767bb5cf35505e6d4da24eff76807fa73bb6ffb88e794654dd4dc" dependencies = [ "bytemuck", "rand_core", @@ -4214,9 +4257,9 @@ dependencies = [ [[package]] name = "risc0-groth16" -version = "1.2.1" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a73e92874649e10cbdd6b3069c4f0f6a7daab1251d18ba8b190ef9f99b39975c" +checksum = "aa2df58accff2fde7e8bad9d144ae91cdfb5d0101addd3365f013fe3e33dccd8" dependencies = [ "anyhow", "ark-bn254", @@ -4235,9 +4278,9 @@ dependencies = [ [[package]] name = "risc0-zkp" -version = "1.2.1" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6f1990995a8933cdd1812dc9d8d0e5f04032a045cc47ef00557996b566e2194" +checksum = "53e429d1cdb86a702eba04a02b3929bdd62a9a1859ec23b281ba2a8d0c6f418f" dependencies = [ "anyhow", "blake2", @@ -4259,16 +4302,16 @@ dependencies = [ [[package]] name = "risc0-zkvm" -version = "1.2.1" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7dd5caa549aa61f00a69f2b625b0d4e42e40595f3d0b29773c80856baa244fd" +checksum = "e7ecc97ec255ad47e1de41b9691a8d92fa48efb779b611d28c3a1c4b7c79abd0" dependencies = [ "anyhow", "bincode", "borsh", "bytemuck", "bytes", - "getrandom", + "getrandom 0.2.15", "hex", "lazy-regex", "prost", @@ -4292,13 +4335,13 @@ dependencies = [ [[package]] name = "risc0-zkvm-platform" -version = "1.2.1" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b825852cf55c5f54f1f21d178055e6959fa5f4e839eab2ad56cfd377d2e7f8" +checksum = "3707a298cacf4d665258b9e976d422401dcfe833f50794fa1e7c20d15ab45e7f" dependencies = [ "bytemuck", "cfg-if", - "getrandom", + "getrandom 0.2.15", "libm", "stability", ] @@ -4358,7 +4401,7 @@ dependencies = [ "regex", "relative-path", "rustc_version 0.4.1", - "syn 2.0.96", + "syn 2.0.98", "unicode-ident", ] @@ -4377,7 +4420,7 @@ dependencies = [ "num-bigint", "num-integer", "num-traits", - "parity-scale-codec 3.6.12", + "parity-scale-codec 3.7.4", "primitive-types 0.12.2", "proptest", "rand", @@ -4402,9 +4445,9 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" [[package]] name = "rustc-hex" @@ -4445,9 +4488,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.21" +version = "0.23.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f287924602bf649d949c63dc8ac8b235fa5387d394020705b80c4eb597ce5b8" +checksum = "47796c98c480fce5406ef69d1c76378375492c3b0a0de587be0c1d9feb12f395" dependencies = [ "once_cell", "ring", @@ -4477,9 +4520,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2bf47e6ff922db3825eb750c4e2ff784c6ff8fb9e13046ef6a1d1c5401b0b37" +checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c" dependencies = [ "web-time 1.1.0", ] @@ -4515,9 +4558,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" [[package]] name = "schannel" @@ -4654,14 +4697,14 @@ checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] name = "serde_json" -version = "1.0.137" +version = "1.0.138" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "930cfb6e6abf99298aaad7d29abbef7a9999a9a8806a40088f55f0dcec03146b" +checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" dependencies = [ "itoa", "memchr", @@ -4677,7 +4720,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -4700,7 +4743,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -4924,7 +4967,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d904e7009df136af5297832a3ace3370cd14ff1546a232f4f185036c2736fcac" dependencies = [ "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -4949,9 +4992,9 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "stacker" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799c883d55abdb5e98af1a7b3f23b9b6de8ecada0ecac058672d7635eb48ca7b" +checksum = "1d08feb8f695b465baed819b03c128dc23f57a694510ab1f06c77f763975685e" dependencies = [ "cc", "cfg-if", @@ -4991,7 +5034,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -5019,9 +5062,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.96" +version = "2.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" dependencies = [ "proc-macro2", "quote", @@ -5030,14 +5073,14 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.19" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b84e4d83a0a6704561302b917a932484e1cae2d8c6354c64be8b7bac1c1fe057" +checksum = "9c2de690018098e367beeb793991c7d4dc7270f42c9d2ac4ccc876c1368ca430" dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -5057,7 +5100,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -5089,13 +5132,13 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.15.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" +checksum = "38c246215d7d24f48ae091a2902398798e05d978b24315d6efbc00ede9a8bb91" dependencies = [ "cfg-if", "fastrand", - "getrandom", + "getrandom 0.3.1", "once_cell", "rustix", "windows-sys 0.59.0", @@ -5127,7 +5170,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -5138,7 +5181,7 @@ checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -5232,7 +5275,7 @@ source = "git+https://github.com/tlsnotary/tlsn?rev=v0.1.0-alpha.6#3554db83e17b2 dependencies = [ "bimap", "bytes", - "getrandom", + "getrandom 0.2.15", "mpz-circuits", "mpz-core", "mpz-garble-core", @@ -5320,7 +5363,7 @@ checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -5387,13 +5430,13 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.22" +version = "0.22.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" +checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" dependencies = [ "indexmap", "toml_datetime", - "winnow 0.6.24", + "winnow 0.7.2", ] [[package]] @@ -5443,7 +5486,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -5534,9 +5577,9 @@ checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" [[package]] name = "unicode-ident" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11cd88e12b17c6494200a9c1b683a04fcac9573ed74cd1b62aeb2727c5592243" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" [[package]] name = "unicode-width" @@ -5581,11 +5624,11 @@ checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" [[package]] name = "uuid" -version = "1.12.1" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3758f5e68192bb96cc8f9b7e2c2cfdabb435499a28499a42f8f984092adad4b" +checksum = "ced87ca4be083373936a67f8de945faa23b6b42384bd5b64434850802c6dccd0" dependencies = [ - "getrandom", + "getrandom 0.3.1", ] [[package]] @@ -5664,7 +5707,7 @@ dependencies = [ "candid", "easy-hasher", "eth-encode-packed", - "getrandom", + "getrandom 0.2.15", "hex", "httparse", "ic-cdk 0.17.1", @@ -5735,9 +5778,9 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wait-timeout" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11" dependencies = [ "libc", ] @@ -5757,6 +5800,15 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasi" +version = "0.13.3+wasi-0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +dependencies = [ + "wit-bindgen-rt", +] + [[package]] name = "wasm-bindgen" version = "0.2.100" @@ -5779,7 +5831,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", "wasm-bindgen-shared", ] @@ -5814,7 +5866,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5883,9 +5935,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.7" +version = "0.26.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d642ff16b7e79272ae451b7322067cdc17cadf68c23264be9d94a32319efe7e" +checksum = "2210b291f7ea53617fbafcc4939f10914214ec15aace5ba62293a668f322c5c9" dependencies = [ "rustls-pki-types", ] @@ -6101,13 +6153,22 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.24" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d71a593cc5c42ad7876e2c1fda56f314f3754c084128833e64f1345ff8a03a" +checksum = "59690dea168f2198d1a3b0cac23b8063efcd11012f10ae4698f284808c8ef603" dependencies = [ "memchr", ] +[[package]] +name = "wit-bindgen-rt" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +dependencies = [ + "bitflags 2.8.0", +] + [[package]] name = "write16" version = "1.0.0" @@ -6155,7 +6216,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", "synstructure", ] @@ -6177,7 +6238,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -6197,7 +6258,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", "synstructure", ] @@ -6218,7 +6279,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -6240,5 +6301,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] diff --git a/ic/managed/verifier/src/lib.rs b/ic/managed/verifier/src/lib.rs index 39d87da07f..c6a9f23931 100644 --- a/ic/managed/verifier/src/lib.rs +++ b/ic/managed/verifier/src/lib.rs @@ -1,21 +1,18 @@ use crate::state::CONFIG; use candid::Principal; use ic_cdk::storage; -use proof::{ - verify_and_sign_proof_requests, - verify_proof_requests, - verify_proof_requests_batch, - verify_and_sign_proof_requests_batch, - ProofBatch, - DirectVerificationResponse }; +use proof::{ + verify_and_sign_proof_requests, verify_and_sign_proof_requests_batch, verify_proof_requests, + verify_proof_requests_batch, DirectVerificationResponse, ProofBatch, +}; use utils::init_canister; use verity_ic::{ - crypto::{ - config::{ Config, Environment }, - ecdsa::{ self, ECDSAPublicKeyReply, PublicKeyReply }, - ethereum, - }, - verify::types::ProofResponse, + crypto::{ + config::{Config, Environment}, + ecdsa::{self, ECDSAPublicKeyReply, PublicKeyReply}, + ethereum, + }, + verify::types::ProofResponse, }; pub mod merkle; @@ -26,78 +23,78 @@ pub mod utils; /// Initializes the canister with an optional environment configuration #[ic_cdk::init] fn init(env_opt: Option) { - init_canister(env_opt); + init_canister(env_opt); } /// A simple test function that returns "Ping" #[ic_cdk::query] fn ping() -> String { - format!("Ping") + format!("Ping") } /// Asynchronously verifies proof requests; intended for canister calls #[ic_cdk::update] async fn verify_proof_async( - proof_requests: Vec, - notary_pub_key: String + proof_requests: Vec, + notary_pub_key: String, ) -> Vec { - let verification_response = verify_proof_requests(proof_requests, notary_pub_key); - verification_response + let verification_response = verify_proof_requests(proof_requests, notary_pub_key); + verification_response } /// Asynchronously verifies batch proof requests; intended for canister calls #[ic_cdk::update] -async fn verify_proof_async_batch( - batches: Vec -) ->Vec { - let verification_responses = verify_proof_requests_batch(batches); - verification_responses - +async fn verify_proof_async_batch(batches: Vec) -> Vec { + let verification_responses = verify_proof_requests_batch(batches); + verification_responses } /// Asynchronously verifies proof requests; intended for direct user calls /// Returns a detailed verification response #[ic_cdk::update] async fn verify_proof_direct( - proof_requests: Vec, - notary_pub_key: String + proof_requests: Vec, + notary_pub_key: String, ) -> Result { - verify_and_sign_proof_requests(proof_requests, notary_pub_key).await + verify_and_sign_proof_requests(proof_requests, notary_pub_key).await } /// Asynchronously verifies proof requests; intended for direct user calls /// Returns a detailed verification response #[ic_cdk::update] async fn verify_proof_direct_batch( - batches: Vec + batches: Vec, ) -> Result { - verify_and_sign_proof_requests_batch(batches).await + verify_and_sign_proof_requests_batch(batches).await } /// Retrieves the public key of the canister #[ic_cdk::update] async fn public_key() -> PublicKeyReply { - let config = crate::CONFIG.with(|c| c.borrow().clone()); - - let request = ecdsa::ECDSAPublicKey { - canister_id: None, - derivation_path: vec![], - key_id: config.key.to_key_id(), - }; - - let (res,): (ECDSAPublicKeyReply,) = ic_cdk - ::call(Principal::management_canister(), "ecdsa_public_key", (request,)).await - .map_err(|e| format!("ECDSA_PUBLIC_KEY_FAILED {}", e.1)) - .unwrap(); - - let address = ethereum - ::get_address_from_public_key(res.public_key.clone()) - .expect("INVALID_PUBLIC_KEY"); - - PublicKeyReply { - sec1_pk: hex::encode(res.public_key), - etherum_pk: address, - } + let config = crate::CONFIG.with(|c| c.borrow().clone()); + + let request = ecdsa::ECDSAPublicKey { + canister_id: None, + derivation_path: vec![], + key_id: config.key.to_key_id(), + }; + + let (res,): (ECDSAPublicKeyReply,) = ic_cdk::call( + Principal::management_canister(), + "ecdsa_public_key", + (request,), + ) + .await + .map_err(|e| format!("ECDSA_PUBLIC_KEY_FAILED {}", e.1)) + .unwrap(); + + let address = + ethereum::get_address_from_public_key(res.public_key.clone()).expect("INVALID_PUBLIC_KEY"); + + PublicKeyReply { + sec1_pk: hex::encode(res.public_key), + etherum_pk: address, + } } // --------------------------- upgrade hooks ------------------------- // @@ -105,17 +102,17 @@ async fn public_key() -> PublicKeyReply { /// Backs up the state variables #[ic_cdk::pre_upgrade] fn pre_upgrade() { - let cloned_config = CONFIG.with(|rc| rc.borrow().clone()); - storage::stable_save((cloned_config,)).unwrap() + let cloned_config = CONFIG.with(|rc| rc.borrow().clone()); + storage::stable_save((cloned_config,)).unwrap() } /// Hook called when the contract is restored or upgraded /// Restores the state variables #[ic_cdk::post_upgrade] async fn post_upgrade() { - let (old_config,): (Config,) = storage::stable_restore().unwrap(); + let (old_config,): (Config,) = storage::stable_restore().unwrap(); - let env_opt = Some(old_config.env); - init_canister(env_opt); + let env_opt = Some(old_config.env); + init_canister(env_opt); } // --------------------------- upgrade hooks ------------------------- // diff --git a/ic/managed/verifier/src/merkle.rs b/ic/managed/verifier/src/merkle.rs index 01333645b8..563fac1073 100644 --- a/ic/managed/verifier/src/merkle.rs +++ b/ic/managed/verifier/src/merkle.rs @@ -1,21 +1,21 @@ -use rs_merkle::{ algorithms::Sha256, Hasher, MerkleTree }; +use rs_merkle::{algorithms::Sha256, Hasher, MerkleTree}; use verity_ic::verify::types::ProofResponse; /// Generates a Merkle tree from a vector of ProofResponse objects. /// Each ProofResponse is hashed to create the leaves of the tree. pub fn generate_merkle_tree(leaves: &Vec) -> MerkleTree { - // Convert each ProofResponse into a 32-byte hash to serve as a leaf in the Merkle tree. - let leaves: Vec<[u8; 32]> = leaves - .iter() - .map(|proof_response| { - let proof_text_content = proof_response.get_content(); - let proof_byte_content = proof_text_content.as_bytes(); + // Convert each ProofResponse into a 32-byte hash to serve as a leaf in the Merkle tree. + let leaves: Vec<[u8; 32]> = leaves + .iter() + .map(|proof_response| { + let proof_text_content = proof_response.get_content(); + let proof_byte_content = proof_text_content.as_bytes(); - Sha256::hash(proof_byte_content) - }) - .collect(); + Sha256::hash(proof_byte_content) + }) + .collect(); - // Construct the Merkle tree from the hashed leaves. - let tree: MerkleTree = MerkleTree::::from_leaves(&leaves); - return tree; + // Construct the Merkle tree from the hashed leaves. + let tree: MerkleTree = MerkleTree::::from_leaves(&leaves); + return tree; } diff --git a/ic/managed/verifier/src/proof.rs b/ic/managed/verifier/src/proof.rs index ccbd250f2d..0a514809f8 100644 --- a/ic/managed/verifier/src/proof.rs +++ b/ic/managed/verifier/src/proof.rs @@ -2,19 +2,20 @@ use candid::CandidType; use serde::Deserialize; use serde_json::Value; use verity_ic::{ - crypto::ethereum::sign_message, - remittance::state::CONFIG, - verify::types::ProofResponse, + crypto::ethereum::sign_message, remittance::state::CONFIG, verify::types::ProofResponse, }; -use verity_verify_tls::{ verify_proof, verify_session }; +use verity_verify_tls::{verify_proof, verify_session}; -use crate::{ merkle::generate_merkle_tree, utils::{ hash, validate_json_proof } }; +use crate::{ + merkle::generate_merkle_tree, + utils::{hash, validate_json_proof}, +}; #[derive(CandidType, Deserialize, Debug, Clone)] pub struct DirectVerificationResponse { - pub results: Vec, - pub root: String, - pub signature: String, + pub results: Vec, + pub root: String, + pub signature: String, } #[derive(CandidType, Deserialize)] @@ -25,128 +26,136 @@ pub struct ProofBatch { #[derive(CandidType, Deserialize, Debug, Clone)] pub enum ProofRequest { - SessionProof(String), - FullProof(String), + SessionProof(String), + FullProof(String), } impl TryFrom for ProofRequest { - type Error = String; + type Error = String; - fn try_from(proof_string: String) -> Result { - let full_proof_keys = vec!["session", "substrings"]; - let session_proof_keys = vec!["header", "signature", "session_info"]; + fn try_from(proof_string: String) -> Result { + let full_proof_keys = vec!["session", "substrings"]; + let session_proof_keys = vec!["header", "signature", "session_info"]; - let proof_json: Value = serde_json::from_str(proof_string.as_str()).unwrap(); + let proof_json: Value = serde_json::from_str(proof_string.as_str()).unwrap(); - // check the keys present in the proof to determine what kind of proof it is - if validate_json_proof(&proof_json, &full_proof_keys) { - return Ok(ProofRequest::FullProof(proof_string)); - } + // check the keys present in the proof to determine what kind of proof it is + if validate_json_proof(&proof_json, &full_proof_keys) { + return Ok(ProofRequest::FullProof(proof_string)); + } - if validate_json_proof(&proof_json, &session_proof_keys) { - return Ok(ProofRequest::SessionProof(proof_string)); - } + if validate_json_proof(&proof_json, &session_proof_keys) { + return Ok(ProofRequest::SessionProof(proof_string)); + } - Err("INVALID PROOF".to_string()) - } + Err("INVALID PROOF".to_string()) + } } impl ProofRequest { - /// Depending on the kind of proof we are trying to verify - /// Check and use the appropriate verifier on the input proof - pub fn verify_request(&self, notary_pub_key: &String) -> Result { - match self { - // verify the session proof and return a hash of the input as a response - ProofRequest::SessionProof(proof_string) => { - let _ = verify_session(&proof_string, ¬ary_pub_key)?; - let response = hash(&proof_string); - Ok(ProofResponse::SessionProof(response)) - } - // verify the full proof and return the request/response pair - ProofRequest::FullProof(proof_string) => { - let (res, req) = verify_proof(&proof_string, ¬ary_pub_key)?; - let response = format!("{}\n\n{}", req, res); - Ok(ProofResponse::FullProof(response)) - } - } - } + /// Depending on the kind of proof we are trying to verify + /// Check and use the appropriate verifier on the input proof + pub fn verify_request(&self, notary_pub_key: &String) -> Result { + match self { + // verify the session proof and return a hash of the input as a response + ProofRequest::SessionProof(proof_string) => { + let _ = verify_session(&proof_string, ¬ary_pub_key)?; + let response = hash(&proof_string); + Ok(ProofResponse::SessionProof(response)) + } + // verify the full proof and return the request/response pair + ProofRequest::FullProof(proof_string) => { + let (res, req) = verify_proof(&proof_string, ¬ary_pub_key)?; + let response = format!("{}\n\n{}", req, res); + Ok(ProofResponse::FullProof(response)) + } + } + } } pub fn verify_proof_requests( - proof_requests: Vec, - notary_pub_key: String + proof_requests: Vec, + notary_pub_key: String, ) -> Vec { - // by default icp escapes special characters, so we need to unescape them - let notary_pub_key = notary_pub_key.replace("\\n", "\n"); - - // convert the string proofs to the actual type casted version of the proof - let proof_requests: Vec = proof_requests - .iter() - .map(|proof_request| proof_request.clone().try_into().unwrap()) - .collect(); - - // iterate through the proofs and try verifying them - let proof_responses: Vec = proof_requests - .iter() - .map(|proof_request| { proof_request.clone().verify_request(¬ary_pub_key).unwrap() }) - .collect(); - - proof_responses + // by default icp escapes special characters, so we need to unescape them + let notary_pub_key = notary_pub_key.replace("\\n", "\n"); + + // convert the string proofs to the actual type casted version of the proof + let proof_requests: Vec = proof_requests + .iter() + .map(|proof_request| proof_request.clone().try_into().unwrap()) + .collect(); + + // iterate through the proofs and try verifying them + let proof_responses: Vec = proof_requests + .iter() + .map(|proof_request| { + proof_request + .clone() + .verify_request(¬ary_pub_key) + .unwrap() + }) + .collect(); + + proof_responses } - pub fn verify_proof_requests_batch(batches: Vec) -> Vec { - batches.into_iter().flat_map(|batch| { - // Unescape special characters in the public key. - let notary_pub_key = batch.notary_pub_key.replace("\\n", "\n"); - - // Process each proof request in this batch. - batch.proof_requests.into_iter().map(|proof_str| { - let proof_request: ProofRequest = proof_str.try_into().unwrap(); - proof_request.verify_request(¬ary_pub_key).unwrap() - }).collect::>() - }).collect() + batches + .into_iter() + .flat_map(|batch| { + // Unescape special characters in the public key. + let notary_pub_key = batch.notary_pub_key.replace("\\n", "\n"); + + // Process each proof request in this batch. + batch + .proof_requests + .into_iter() + .map(|proof_str| { + let proof_request: ProofRequest = proof_str.try_into().unwrap(); + proof_request.verify_request(¬ary_pub_key).unwrap() + }) + .collect::>() + }) + .collect() } - async fn process_and_sign( - proof_responses: Vec -)->Result{ + proof_responses: Vec, +) -> Result { // generate a merkle tree based on the content of the proof responses as leaves - let merkle_tree = generate_merkle_tree(&proof_responses); - let merkle_root = merkle_tree.root().expect("NOT ENOUGH LEAVES"); - let merkle_root = hex::encode(merkle_root); - - // perform an ecdsa signature over this merkle root and return it - // generate a signature for these parameters - let config_store = CONFIG.with(|store| store.borrow().clone()); - let signature_reply = sign_message(&merkle_root.clone().into_bytes(), &config_store).await?; - let signature = signature_reply.signature_hex; - - Ok(DirectVerificationResponse { - results: proof_responses, - root: merkle_root.clone(), - signature, - }) + let merkle_tree = generate_merkle_tree(&proof_responses); + let merkle_root = merkle_tree.root().expect("NOT ENOUGH LEAVES"); + let merkle_root = hex::encode(merkle_root); + + // perform an ecdsa signature over this merkle root and return it + // generate a signature for these parameters + let config_store = CONFIG.with(|store| store.borrow().clone()); + let signature_reply = sign_message(&merkle_root.clone().into_bytes(), &config_store).await?; + let signature = signature_reply.signature_hex; + + Ok(DirectVerificationResponse { + results: proof_responses, + root: merkle_root.clone(), + signature, + }) } pub async fn verify_and_sign_proof_requests( - proof_requests: Vec, - notary_pub_key: String + proof_requests: Vec, + notary_pub_key: String, ) -> Result { - // iterate through the proofs and try verifying them - let proof_responses: Vec = verify_proof_requests(proof_requests, notary_pub_key); + // iterate through the proofs and try verifying them + let proof_responses: Vec = verify_proof_requests(proof_requests, notary_pub_key); - return process_and_sign(proof_responses).await; + return process_and_sign(proof_responses).await; } - - pub async fn verify_and_sign_proof_requests_batch( - batches :Vec + batches: Vec, ) -> Result { - // iterate through the proofs and try verifying them - let proof_responses: Vec = verify_proof_requests_batch(batches); + // iterate through the proofs and try verifying them + let proof_responses: Vec = verify_proof_requests_batch(batches); - return process_and_sign(proof_responses).await; -} \ No newline at end of file + return process_and_sign(proof_responses).await; +} diff --git a/ic/managed/verifier/src/state.rs b/ic/managed/verifier/src/state.rs index 56eb6470a7..8f0cd31101 100644 --- a/ic/managed/verifier/src/state.rs +++ b/ic/managed/verifier/src/state.rs @@ -1,6 +1,6 @@ -use verity_ic::crypto::config::Config; use std::cell::RefCell; +use verity_ic::crypto::config::Config; thread_local! { - pub static CONFIG: RefCell = RefCell::default(); + pub static CONFIG: RefCell = RefCell::default(); } diff --git a/ic/managed/verifier/src/utils.rs b/ic/managed/verifier/src/utils.rs index 30c1327816..b1397f5491 100644 --- a/ic/managed/verifier/src/utils.rs +++ b/ic/managed/verifier/src/utils.rs @@ -1,39 +1,42 @@ use crate::state::CONFIG; -use rs_merkle::{ algorithms::Sha256, Hasher }; +use rs_merkle::{algorithms::Sha256, Hasher}; use serde_json::Value; -use verity_ic::{ crypto::config::{ Config, Environment }, owner }; +use verity_ic::{ + crypto::config::{Config, Environment}, + owner, +}; /// Initialise the canister's environment pub fn init_canister(env_opt: Option) { - owner::init_owner(); - ic_wasi_polyfill::init(&[0u8; 32], &[]); + owner::init_owner(); + ic_wasi_polyfill::init(&[0u8; 32], &[]); - // save the environment this is running in - // defaults to staging - if let Some(env) = env_opt { - CONFIG.with(|s| { - let mut state = s.borrow_mut(); - *state = Config::from(env); - }) - } + // save the environment this is running in + // defaults to staging + if let Some(env) = env_opt { + CONFIG.with(|s| { + let mut state = s.borrow_mut(); + *state = Config::from(env); + }) + } } /// Checks the proof json if it contains all the keys present in the vector of strings /// returns an error if the provided json does not contain all of the provided keys pub fn validate_json_proof(proof_json: &Value, json_keys: &Vec<&str>) -> bool { - let condition = |key: &&str| proof_json.get(key).is_some(); + let condition = |key: &&str| proof_json.get(key).is_some(); - json_keys.iter().all(condition) + json_keys.iter().all(condition) } /// Perform a SHA 256 hash on the input string /// Return a hex encoded value as the response pub fn hash(input: &String) -> String { - let input = input.as_bytes(); - // Convert the input string to bytes and hash it - let hash = Sha256::hash(input); - // Convert the resulting hash into a hexadecimal string and return it - let hex_hash = hex::encode(hash); + let input = input.as_bytes(); + // Convert the input string to bytes and hash it + let hash = Sha256::hash(input); + // Convert the resulting hash into a hexadecimal string and return it + let hex_hash = hex::encode(hash); - hex_hash + hex_hash }