From 2ebaa169b25f55c8a5855675e7369c2f8fe0b338 Mon Sep 17 00:00:00 2001 From: ada Date: Fri, 12 Feb 2021 20:47:13 +0100 Subject: [PATCH] jubjub solved --- lisp/lisp.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lisp/lisp.rs b/lisp/lisp.rs index a69f037ae..c5c53637f 100644 --- a/lisp/lisp.rs +++ b/lisp/lisp.rs @@ -545,7 +545,7 @@ pub fn prove(_ast: MalVal, env: Env) -> MalRet { let allocs = get_allocations(&env, "Allocations"); let enforce_allocs = get_enforce_allocs(&env); let allocs_const = get_allocations(&env, "AllocationsConst"); - + //setup let params = Some({ let circuit = LispCircuit { params: allocs_const.as_ref().clone(), @@ -556,7 +556,7 @@ pub fn prove(_ast: MalVal, env: Env) -> MalRet { groth16::generate_random_parameters::(circuit, &mut OsRng)? }); let verifying_key = Some(groth16::prepare_verifying_key(¶ms.as_ref().unwrap().vk)); - + // prove let circuit = LispCircuit { params: allocs_const.as_ref().clone(), allocs: allocs.as_ref().clone(), @@ -565,15 +565,20 @@ pub fn prove(_ast: MalVal, env: Env) -> MalRet { }; let proof = groth16::create_random_proof(circuit, params.as_ref().unwrap(), &mut OsRng)?; -// todo save the proof and keys on a file - let mut vec_public = Vec::new(); + let mut vec_input = vec![]; + for (k, val) in allocs_input.iter() { + println!("{:?}", val); + if let MalVal::Str(v) = val { + vec_input.push(bls12_381::Scalar::from_string(&v.to_string())); + } + } let result = groth16::verify_proof( verifying_key.as_ref().unwrap(), &proof, - &vec_public, + &vec_input, ); - println!("vec public {:?}", vec_public); println!("{:?}", result); + println!("vec public {:?}", vec_input); Ok(MalVal::Nil) }