diff --git a/lisp/lisp.rs b/lisp/lisp.rs index c5c53637f..01b8e5f33 100644 --- a/lisp/lisp.rs +++ b/lisp/lisp.rs @@ -168,7 +168,9 @@ fn eval(mut ast: MalVal, mut env: Env) -> MalRet { env_set(&env, l[1].clone(), eval(l[2].clone(), env.clone())?) } Sym(ref a0sym) if a0sym == "let*" => { - env = env_new(Some(env.clone())); + // TODO let should be restored to the first purpose + // and the new let* without an env creation should be availaable + // env = env_new(Some(env.clone())); let (a1, a2) = (l[1].clone(), l[2].clone()); match a1 { List(ref binds, _) | Vector(ref binds, _) => { @@ -427,7 +429,7 @@ fn eval(mut ast: MalVal, mut env: Env) -> MalRet { output: out_vec, }; let mut new_vec: Vec = vec![enforce]; - for value in enforce_vec.iter() { + for value in enforce_vec.iter() { new_vec.push(value.clone()); } env_set( @@ -547,12 +549,12 @@ pub fn prove(_ast: MalVal, env: Env) -> MalRet { let allocs_const = get_allocations(&env, "AllocationsConst"); //setup let params = Some({ - let circuit = LispCircuit { - params: allocs_const.as_ref().clone(), - allocs: allocs.as_ref().clone(), - alloc_inputs: allocs_input.as_ref().clone(), - constraints: enforce_allocs.clone(), - }; + let circuit = LispCircuit { + params: allocs_const.as_ref().clone(), + allocs: allocs.as_ref().clone(), + alloc_inputs: allocs_input.as_ref().clone(), + constraints: enforce_allocs.clone(), + }; groth16::generate_random_parameters::(circuit, &mut OsRng)? }); let verifying_key = Some(groth16::prepare_verifying_key(¶ms.as_ref().unwrap().vk)); @@ -568,15 +570,17 @@ pub fn prove(_ast: MalVal, env: Env) -> MalRet { 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())); - } + match val { + MalVal::Str(v) => { + vec_input.push(bls12_381::Scalar::from_string(&v.to_string())); + } + MalVal::ZKScalar(v) => { + vec_input.push(bls12_381::Scalar::from(*v)); + } + _ => {} + }; } - let result = groth16::verify_proof( - verifying_key.as_ref().unwrap(), - &proof, - &vec_input, - ); + let result = groth16::verify_proof(verifying_key.as_ref().unwrap(), &proof, &vec_input); println!("{:?}", result); println!("vec public {:?}", vec_input); diff --git a/lisp/run.sh b/lisp/run.sh index dd8118bac..913940183 100755 --- a/lisp/run.sh +++ b/lisp/run.sh @@ -1,3 +1,3 @@ export RUST_BACKTRACE=full -cargo run --bin lisp load jubjub-add.lisp +cargo run --bin lisp load jubjub-mul.lisp #cargo run --bin lisp load new-cs.lisp diff --git a/lisp/types.rs b/lisp/types.rs index 36f8c8669..ea886a8c8 100644 --- a/lisp/types.rs +++ b/lisp/types.rs @@ -38,7 +38,7 @@ pub struct LispCircuit { pub params: FnvHashMap, pub allocs: FnvHashMap, pub alloc_inputs: FnvHashMap, -// todo change this for a ordered data structure so enforce + // todo change this for a ordered data structure so enforce pub constraints: Vec, } @@ -118,7 +118,7 @@ impl Circuit for LispCircuit { println!("Enforce Allocations\n"); let mut enforce_sorted = self.constraints.clone(); - enforce_sorted.sort_by(|a, b| a.idx.cmp(&b.idx)); + enforce_sorted.sort_by(|a, b| a.idx.cmp(&b.idx)); for alloc_value in enforce_sorted.iter() { println!("Enforce -> {:?}", alloc_value); let coeff = bls12_381::Scalar::one();