mirror of
https://github.com/vacp2p/semaphore-rs.git
synced 2025-02-24 01:28:28 +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 }
|
||||
rayon = "1.5.1"
|
||||
|
||||
[dev-dependencies]
|
||||
tiny-keccak = "2.0.2"
|
||||
serde_json = "1.0.79"
|
||||
|
||||
[patch.crates-io]
|
||||
wasmer = { git = 'https://github.com/philsippl/wasmer', rev = "e776616"}
|
||||
|
||||
|
@ -9,7 +9,7 @@ use ark_bn254::Parameters;
|
||||
use ark_ec::bn::Bn;
|
||||
use ark_groth16::Proof;
|
||||
use hex_literal::hex;
|
||||
use num_bigint::{BigInt};
|
||||
use num_bigint::BigInt;
|
||||
use poseidon_tree::PoseidonHash;
|
||||
use protocol::SnarkFileConfig;
|
||||
use std::{
|
||||
@ -243,7 +243,7 @@ pub unsafe extern "C" fn verify_proof(
|
||||
protocol::verify_proof(
|
||||
&config,
|
||||
&root,
|
||||
&nullifier,
|
||||
&nullifier,
|
||||
signal.as_bytes(),
|
||||
external_nullifier.as_bytes(),
|
||||
proof,
|
||||
|
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 success =
|
||||
verify_proof(&config, &root, &nullifier_hash, signal, external_nullifier, &proof).unwrap();
|
||||
let success = verify_proof(
|
||||
&config,
|
||||
&root,
|
||||
&nullifier_hash,
|
||||
signal,
|
||||
external_nullifier,
|
||||
&proof,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
dbg!(success);
|
||||
}
|
||||
|
@ -221,16 +221,21 @@ where
|
||||
#[cfg(test)]
|
||||
pub mod test {
|
||||
use super::*;
|
||||
use ethers::utils::keccak256;
|
||||
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];
|
||||
|
||||
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]
|
||||
fn test_root() {
|
||||
let mut tree = MerkleTree::<Keccak>::new(3, [0; 32]);
|
||||
let mut tree = MerkleTree::<Keccak256>::new(3, [0; 32]);
|
||||
assert_eq!(
|
||||
tree.root(),
|
||||
hex!("b4c11951957c6f8f642c4af61cd6b24640fec6dc7fc607ee8206a99e92410d30")
|
||||
@ -295,7 +300,7 @@ pub mod test {
|
||||
|
||||
#[test]
|
||||
fn test_proof() {
|
||||
let mut tree = MerkleTree::<Keccak>::new(3, [0; 32]);
|
||||
let mut tree = MerkleTree::<Keccak256>::new(3, [0; 32]);
|
||||
tree.set(
|
||||
0,
|
||||
hex!("0000000000000000000000000000000000000000000000000000000000000001"),
|
||||
@ -327,7 +332,7 @@ pub mod test {
|
||||
|
||||
#[test]
|
||||
fn test_position() {
|
||||
let mut tree = MerkleTree::<Keccak>::new(3, [0; 32]);
|
||||
let mut tree = MerkleTree::<Keccak256>::new(3, [0; 32]);
|
||||
tree.set(
|
||||
0,
|
||||
hex!("0000000000000000000000000000000000000000000000000000000000000001"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user