style(rln): cargo fmt

This commit is contained in:
Oskar Thoren 2022-05-23 08:07:10 +01:00
parent f2f3c820ff
commit 1d8408d743
No known key found for this signature in database
GPG Key ID: B2ECCFD3BC2EF77E
2 changed files with 24 additions and 16 deletions

View File

@ -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<Bn<Parameters>>;
@ -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() {

View File

@ -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;