Skip to content

Commit

Permalink
cargo fmt nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
pdtfh committed Sep 16, 2024
1 parent aa01a10 commit 4c0c3ee
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 30 deletions.
45 changes: 23 additions & 22 deletions crates/ark-zkey/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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<Bn254>);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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(())
// }
Expand All @@ -292,25 +292,26 @@ 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()
// }

// // #[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(())
Expand Down
4 changes: 2 additions & 2 deletions crates/semaphore-depth-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ impl VisitMut for IdentReplacer {
}
}
syn::Expr::Macro(mcr) => {
let Ok(mut args) = mcr.mac.parse_body::<MacroArgs>() else {
return;
let Ok(mut args) = mcr.mac.parse_body::<MacroArgs>() else {
return;
};
for arg in &mut args.args {
self.visit_expr_mut(arg);
Expand Down
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions src/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]),
]);

Expand Down

0 comments on commit 4c0c3ee

Please sign in to comment.