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_bn254::{Fr, Parameters};
use ark_ec::bn::Bn; use ark_ec::bn::Bn;
pub mod protocol;
pub mod circuit; pub mod circuit;
pub mod protocol;
pub type Field = Fr; pub type Field = Fr;
pub type Groth16Proof = ark_groth16::Proof<Bn<Parameters>>; pub type Groth16Proof = ark_groth16::Proof<Bn<Parameters>>;
@ -21,10 +21,10 @@ pub mod poseidon;
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use crate::protocol::*;
use hex_literal::hex; use hex_literal::hex;
use num_bigint::BigInt; use num_bigint::BigInt;
use semaphore::{hash::Hash, identity::Identity, poseidon_tree::PoseidonTree}; use semaphore::{hash::Hash, identity::Identity, poseidon_tree::PoseidonTree};
use crate::protocol::*;
#[test] #[test]
fn test_merkle_proof() { fn test_merkle_proof() {
@ -66,19 +66,27 @@ mod test {
let signal = b"xxx"; let signal = b"xxx";
let external_nullifier = b"appId"; let external_nullifier = b"appId";
let external_nullifier_hash = semaphore::protocol::hash_external_nullifier(external_nullifier); let external_nullifier_hash =
let nullifier_hash = semaphore::protocol::generate_nullifier_hash(&id, 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 = let success = semaphore::protocol::verify_proof(
semaphore::protocol::verify_proof(root, nullifier_hash, signal, external_nullifier, &proof).unwrap(); root,
nullifier_hash,
signal,
external_nullifier,
&proof,
)
.unwrap();
assert!(success); assert!(success);
} }
#[ignore] #[ignore]
#[test] #[test]
fn test_end_to_end() { fn test_end_to_end() {

View File

@ -1,12 +1,5 @@
/// Adapted from semaphore-rs /// Adapted from semaphore-rs
use crate::circuit::{WITNESS_CALCULATOR, ZKEY}; 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_bn254::{Bn254, Parameters};
use ark_circom::CircomReduction; use ark_circom::CircomReduction;
use ark_ec::bn::Bn; use ark_ec::bn::Bn;
@ -17,6 +10,13 @@ use ark_std::{rand::thread_rng, UniformRand};
use color_eyre::Result; use color_eyre::Result;
use ethers_core::utils::keccak256; use ethers_core::utils::keccak256;
use num_bigint::{BigInt, BigUint, ToBigInt}; 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 std::time::Instant;
use thiserror::Error; use thiserror::Error;