From 1d8408d743723a486e24905d2bfbfdf6d701bec4 Mon Sep 17 00:00:00 2001 From: Oskar Thoren Date: Mon, 23 May 2022 08:07:10 +0100 Subject: [PATCH] style(rln): cargo fmt --- rln/src/lib.rs | 26 +++++++++++++++++--------- rln/src/protocol.rs | 14 +++++++------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/rln/src/lib.rs b/rln/src/lib.rs index 8699399..320a6a8 100644 --- a/rln/src/lib.rs +++ b/rln/src/lib.rs @@ -7,8 +7,8 @@ pub mod public; use ark_bn254::{Fr, Parameters}; use ark_ec::bn::Bn; -pub mod protocol; pub mod circuit; +pub mod protocol; pub type Field = Fr; pub type Groth16Proof = ark_groth16::Proof>; @@ -21,10 +21,10 @@ pub mod poseidon; #[cfg(test)] mod test { use super::*; + use crate::protocol::*; use hex_literal::hex; use num_bigint::BigInt; use semaphore::{hash::Hash, identity::Identity, poseidon_tree::PoseidonTree}; - use crate::protocol::*; #[test] fn test_merkle_proof() { @@ -66,19 +66,27 @@ mod test { let signal = b"xxx"; let external_nullifier = b"appId"; - let external_nullifier_hash = semaphore::protocol::hash_external_nullifier(external_nullifier); - let nullifier_hash = semaphore::protocol::generate_nullifier_hash(&id, external_nullifier_hash); + let external_nullifier_hash = + semaphore::protocol::hash_external_nullifier(external_nullifier); + let nullifier_hash = + semaphore::protocol::generate_nullifier_hash(&id, external_nullifier_hash); - let proof = semaphore::protocol::generate_proof(&id, &merkle_proof, external_nullifier, signal).unwrap(); + let proof = + semaphore::protocol::generate_proof(&id, &merkle_proof, external_nullifier, signal) + .unwrap(); - let success = - semaphore::protocol::verify_proof(root, nullifier_hash, signal, external_nullifier, &proof).unwrap(); + let success = semaphore::protocol::verify_proof( + root, + nullifier_hash, + signal, + external_nullifier, + &proof, + ) + .unwrap(); assert!(success); } - - #[ignore] #[test] fn test_end_to_end() { diff --git a/rln/src/protocol.rs b/rln/src/protocol.rs index 1a0a67a..f68db36 100644 --- a/rln/src/protocol.rs +++ b/rln/src/protocol.rs @@ -1,12 +1,5 @@ /// Adapted from semaphore-rs use crate::circuit::{WITNESS_CALCULATOR, ZKEY}; -use semaphore::{ - identity::Identity, - merkle_tree::{self, Branch}, - poseidon_hash, - poseidon_tree::PoseidonHash, - Field, -}; use ark_bn254::{Bn254, Parameters}; use ark_circom::CircomReduction; use ark_ec::bn::Bn; @@ -17,6 +10,13 @@ use ark_std::{rand::thread_rng, UniformRand}; use color_eyre::Result; use ethers_core::utils::keccak256; use num_bigint::{BigInt, BigUint, ToBigInt}; +use semaphore::{ + identity::Identity, + merkle_tree::{self, Branch}, + poseidon_hash, + poseidon_tree::PoseidonHash, + Field, +}; use std::time::Instant; use thiserror::Error;