mirror of
https://github.com/vacp2p/semaphore-rs.git
synced 2025-02-24 09:38:34 +00:00
Fix test
This commit is contained in:
parent
45f9ae4566
commit
b775711657
1559
Cargo.lock
generated
1559
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -38,6 +38,10 @@ hex-literal = "0.3"
|
|||||||
proptest = { version = "1.0", optional = true }
|
proptest = { version = "1.0", optional = true }
|
||||||
rayon = "1.5.1"
|
rayon = "1.5.1"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
tiny-keccak = "2.0.2"
|
||||||
|
serde_json = "1.0.79"
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
wasmer = { git = 'https://github.com/philsippl/wasmer', rev = "e776616"}
|
wasmer = { git = 'https://github.com/philsippl/wasmer', rev = "e776616"}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ use ark_bn254::Parameters;
|
|||||||
use ark_ec::bn::Bn;
|
use ark_ec::bn::Bn;
|
||||||
use ark_groth16::Proof;
|
use ark_groth16::Proof;
|
||||||
use hex_literal::hex;
|
use hex_literal::hex;
|
||||||
use num_bigint::{BigInt};
|
use num_bigint::BigInt;
|
||||||
use poseidon_tree::PoseidonHash;
|
use poseidon_tree::PoseidonHash;
|
||||||
use protocol::SnarkFileConfig;
|
use protocol::SnarkFileConfig;
|
||||||
use std::{
|
use std::{
|
||||||
|
11
src/main.rs
11
src/main.rs
@ -47,8 +47,15 @@ fn main() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let proof = generate_proof(&config, &id, &merkle_proof, external_nullifier, signal).unwrap();
|
let proof = generate_proof(&config, &id, &merkle_proof, external_nullifier, signal).unwrap();
|
||||||
let success =
|
let success = verify_proof(
|
||||||
verify_proof(&config, &root, &nullifier_hash, signal, external_nullifier, &proof).unwrap();
|
&config,
|
||||||
|
&root,
|
||||||
|
&nullifier_hash,
|
||||||
|
signal,
|
||||||
|
external_nullifier,
|
||||||
|
&proof,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
dbg!(success);
|
dbg!(success);
|
||||||
}
|
}
|
||||||
|
@ -221,16 +221,21 @@ where
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub mod test {
|
pub mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
use ethers::utils::keccak256;
|
|
||||||
use hex_literal::hex;
|
use hex_literal::hex;
|
||||||
|
use tiny_keccak::{Hasher as _, Keccak};
|
||||||
|
|
||||||
struct Keccak;
|
struct Keccak256;
|
||||||
|
|
||||||
impl Hasher for Keccak {
|
impl Hasher for Keccak256 {
|
||||||
type Hash = [u8; 32];
|
type Hash = [u8; 32];
|
||||||
|
|
||||||
fn hash_node(left: &Self::Hash, right: &Self::Hash) -> Self::Hash {
|
fn hash_node(left: &Self::Hash, right: &Self::Hash) -> Self::Hash {
|
||||||
keccak256([*left, *right].concat())
|
let mut output = [0; 32];
|
||||||
|
let mut hasher = Keccak::v256();
|
||||||
|
hasher.update(left);
|
||||||
|
hasher.update(right);
|
||||||
|
hasher.finalize(&mut output);
|
||||||
|
output
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,7 +259,7 @@ pub mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_root() {
|
fn test_root() {
|
||||||
let mut tree = MerkleTree::<Keccak>::new(3, [0; 32]);
|
let mut tree = MerkleTree::<Keccak256>::new(3, [0; 32]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tree.root(),
|
tree.root(),
|
||||||
hex!("b4c11951957c6f8f642c4af61cd6b24640fec6dc7fc607ee8206a99e92410d30")
|
hex!("b4c11951957c6f8f642c4af61cd6b24640fec6dc7fc607ee8206a99e92410d30")
|
||||||
@ -295,7 +300,7 @@ pub mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_proof() {
|
fn test_proof() {
|
||||||
let mut tree = MerkleTree::<Keccak>::new(3, [0; 32]);
|
let mut tree = MerkleTree::<Keccak256>::new(3, [0; 32]);
|
||||||
tree.set(
|
tree.set(
|
||||||
0,
|
0,
|
||||||
hex!("0000000000000000000000000000000000000000000000000000000000000001"),
|
hex!("0000000000000000000000000000000000000000000000000000000000000001"),
|
||||||
@ -327,7 +332,7 @@ pub mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_position() {
|
fn test_position() {
|
||||||
let mut tree = MerkleTree::<Keccak>::new(3, [0; 32]);
|
let mut tree = MerkleTree::<Keccak256>::new(3, [0; 32]);
|
||||||
tree.set(
|
tree.set(
|
||||||
0,
|
0,
|
||||||
hex!("0000000000000000000000000000000000000000000000000000000000000001"),
|
hex!("0000000000000000000000000000000000000000000000000000000000000001"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user