From 4c0c3ee6af4c5e3e260ce833f649e6794be5db1c Mon Sep 17 00:00:00 2001 From: pdtfh <149602456+pdtfh@users.noreply.github.com> Date: Mon, 16 Sep 2024 21:15:33 +0200 Subject: [PATCH] cargo fmt nightly --- crates/ark-zkey/src/lib.rs | 45 ++++++++++++------------ crates/semaphore-depth-macros/src/lib.rs | 4 +-- src/lib.rs | 7 ++-- src/protocol/mod.rs | 7 ++-- 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/crates/ark-zkey/src/lib.rs b/crates/ark-zkey/src/lib.rs index 32c8691..6f76993 100644 --- a/crates/ark-zkey/src/lib.rs +++ b/crates/ark-zkey/src/lib.rs @@ -1,19 +1,16 @@ use ark_bn254::{Bn254, Fr}; use ark_circom::read_zkey; -//use ark_ec::pairing::Pairing; +// use ark_ec::pairing::Pairing; use ark_ff::Field; use ark_groth16::ProvingKey; -//use ark_groth16::VerifyingKey; +// use ark_groth16::VerifyingKey; use ark_relations::r1cs::ConstraintMatrices; use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; use color_eyre::eyre::{Result, WrapErr}; use memmap2::Mmap; -use std::fs::File; -use std::io::Cursor; -//use std::io::{Read,self}; -use std::io::BufReader; -use std::path::PathBuf; -use std::time::Instant; +use std::{fs::File, io::Cursor}; +// use std::io::{Read,self}; +use std::{io::BufReader, path::PathBuf, time::Instant}; #[derive(CanonicalSerialize, CanonicalDeserialize, Clone, Debug, PartialEq)] pub struct SerializableProvingKey(pub ProvingKey); @@ -103,7 +100,7 @@ pub fn read_arkzkey( let arkzkey_file = File::open(arkzkey_file_path).wrap_err("Failed to open arkzkey file")?; println!("Time to open arkzkey file: {:?}", now.elapsed()); - //let mut buf_reader = BufReader::new(arkzkey_file); + // let mut buf_reader = BufReader::new(arkzkey_file); // Using mmap let now = std::time::Instant::now(); @@ -238,11 +235,13 @@ pub fn convert_zkey( // Ok(()) // } -// fn test_circuit_serialization_deserialization(dir: &str, circuit: &str) -> Result<()> { -// let _zkey_path = format!("{}/target/{}_final.zkey", dir, circuit); -// let arkzkey_path = format!("{}/target/{}_final.arkzkey", dir, circuit); +// fn test_circuit_serialization_deserialization(dir: &str, circuit: &str) +// -> Result<()> { let _zkey_path = format!("{}/target/{}_final.zkey", +// dir, circuit); let arkzkey_path = +// format!("{}/target/{}_final.arkzkey", dir, circuit); -// let (original_proving_key, original_constraint_matrices) = read_proving_key_and_matrices()?; +// let (original_proving_key, original_constraint_matrices) = +// read_proving_key_and_matrices()?; // println!("[build] Writing arkzkey to: {}", arkzkey_path); // let now = Instant::now(); @@ -269,7 +268,8 @@ pub fn convert_zkey( // "Original and deserialized constraint matrices do not match" // ); -// //flame::dump_html(&mut std::fs::File::create("flame-graph.html").unwrap()).unwrap(); +// //flame::dump_html(&mut +// std::fs::File::create("flame-graph.html").unwrap()).unwrap(); // Ok(()) // } @@ -292,11 +292,11 @@ pub fn convert_zkey( // #[test] // fn test_rsa_serialization_deserialization() -> Result<()> { -// test_circuit_serialization_deserialization("../mopro-core/examples/circom/rsa", "main") -// } +// test_circuit_serialization_deserialization("../mopro-core/examples/ +// circom/rsa", "main") } -// // XXX: We do include_bytes for zkey data, so need to manually change this -// #[test] +// // XXX: We do include_bytes for zkey data, so need to manually change +// this #[test] // fn test_circuit_naive_read() -> Result<()> { // circuit_naive_read() // } @@ -304,13 +304,14 @@ pub fn convert_zkey( // // #[test] // // fn test_read_arkzkey_from_bytes() -> Result<()> { // // const ARKZKEY_BYTES: &[u8] = include_bytes!( -// // "../../mopro-core/examples/circom/keccak256/target/keccak256_256_test_final.arkzkey" -// // ); +// // +// "../../mopro-core/examples/circom/keccak256/target/keccak256_256_test_final. +// arkzkey" // ); // // println!("Reading arkzkey from bytes (keccak)"); // // let now = Instant::now(); -// // let (_deserialized_proving_key, _deserialized_constraint_matrices) = -// // read_arkzkey_from_bytes(ARKZKEY_BYTES)?; +// // let (_deserialized_proving_key, _deserialized_constraint_matrices) +// = // read_arkzkey_from_bytes(ARKZKEY_BYTES)?; // // println!("Time to read arkzkey: {:?}", now.elapsed()); // // Ok(()) diff --git a/crates/semaphore-depth-macros/src/lib.rs b/crates/semaphore-depth-macros/src/lib.rs index 377085d..fa2d9e3 100644 --- a/crates/semaphore-depth-macros/src/lib.rs +++ b/crates/semaphore-depth-macros/src/lib.rs @@ -101,8 +101,8 @@ impl VisitMut for IdentReplacer { } } syn::Expr::Macro(mcr) => { - let Ok(mut args) = mcr.mac.parse_body::() else { - return; + let Ok(mut args) = mcr.mac.parse_body::() else { + return; }; for arg in &mut args.args { self.visit_expr_mut(arg); diff --git a/src/lib.rs b/src/lib.rs index b45fe2a..14d2011 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -146,8 +146,11 @@ mod test { #[cfg(feature = "bench")] pub mod bench { use crate::{ - hash_to_field, identity::Identity, poseidon_tree::LazyPoseidonTree, - protocol::{generate_proof, generate_witness}, Field, + hash_to_field, + identity::Identity, + poseidon_tree::LazyPoseidonTree, + protocol::{generate_proof, generate_witness}, + Field, }; use criterion::Criterion; use semaphore_depth_config::get_supported_depths; diff --git a/src/protocol/mod.rs b/src/protocol/mod.rs index 91b951e..95d8438 100644 --- a/src/protocol/mod.rs +++ b/src/protocol/mod.rs @@ -181,10 +181,9 @@ pub fn generate_witness( ("identityTrapdoor".to_owned(), vec![identity.trapdoor]), ("treePathIndices".to_owned(), merkle_proof.path_index()), ("treeSiblings".to_owned(), merkle_proof_to_vec(merkle_proof)), - ( - "externalNullifier".to_owned(), - vec![external_nullifier_hash], - ), + ("externalNullifier".to_owned(), vec![ + external_nullifier_hash, + ]), ("signalHash".to_owned(), vec![signal_hash]), ]);