minor tweaks

This commit is contained in:
psippl 2022-01-31 23:11:09 -08:00
parent 0047d8e7c2
commit 576a3ad937
2 changed files with 15 additions and 9 deletions

View File

@ -31,12 +31,15 @@ fn main() {
let merkle_proof = tree.proof(0).expect("proof should exist");
let root = tree.root().into();
let signal = b"xxx";
let external_nullifier = b"appId";
let nullifier_hash = generate_nullifier_hash(&external_nullifier[..], &id.nullifier);
// change signal and external_nullifier here
let signal = "xxx".as_bytes();
let external_nullifier = "appId".as_bytes();
let proof = generate_proof(&id, &merkle_proof, &external_nullifier[..], &signal[..]).unwrap();
let res = verify_proof(&root, &nullifier_hash, &signal[..], &external_nullifier[..], &proof).unwrap();
let nullifier_hash = generate_nullifier_hash(&external_nullifier, &id.nullifier);
dbg!(&nullifier_hash);
dbg!(res);
let proof = generate_proof(&id, &merkle_proof, &external_nullifier, &signal).unwrap();
let success = verify_proof(&root, &nullifier_hash, &signal, &external_nullifier, &proof).unwrap();
dbg!(success);
}

View File

@ -97,12 +97,17 @@ pub fn generate_proof(
inputs
};
use std::time::Instant;
let now = Instant::now();
let mut wtns = WitnessCalculator::new(format!("{}{}", SNARK_FILES, WASM_FILE)).unwrap();
let full_assignment = wtns
.calculate_witness_element::<Bn254, _>(inputs, false)
.unwrap();
println!("witness generation took: {:.2?}", now.elapsed());
let mut rng = thread_rng();
use ark_std::UniformRand;
let rng = &mut rng;
@ -110,7 +115,6 @@ pub fn generate_proof(
let r = ark_bn254::Fr::rand(rng);
let s = ark_bn254::Fr::rand(rng);
use std::time::Instant;
let now = Instant::now();
let proof = create_proof_with_reduction_and_matrices::<_, CircomReduction>(
@ -123,8 +127,7 @@ pub fn generate_proof(
full_assignment.as_slice(),
);
let elapsed = now.elapsed();
println!("proof generation took: {:.2?}", elapsed);
println!("proof generation took: {:.2?}", now.elapsed());
proof
}