From b808eba531d139f92295ec7337b26419bd08b080 Mon Sep 17 00:00:00 2001 From: ada Date: Mon, 1 Feb 2021 02:07:20 +0100 Subject: [PATCH] begin setup with enforce, alloc and alloc input --- lisp/lisp.rs | 22 +++++++++++----------- lisp/types.rs | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lisp/lisp.rs b/lisp/lisp.rs index 07f742fb7..cbee39a35 100644 --- a/lisp/lisp.rs +++ b/lisp/lisp.rs @@ -414,7 +414,7 @@ fn eval(mut ast: MalVal, mut env: Env) -> MalRet { }; let mut new_vec: Vec = vec![enforce]; for value in get_enforce_allocs(&env).iter() { - println!("found {:?}", value); + new_vec.push(value.clone()); } env_set( &env, @@ -510,15 +510,15 @@ pub fn setup(_ast: MalVal, env: Env) -> Result, MalE let start = Instant::now(); // Create parameters for our circuit. In a production deployment these would // be generated securely using a multiparty computation. - // let allocs_input = get_allocations(&env, "AllocationsInput").to_vec(); - // let allocs = get_allocations(&env, "Allocations").to_vec(); - // let enforce_allocs = get_enforce_allocs(&env).unwrap().to_vec(); + let allocs_input = get_allocations(&env, "AllocationsInput"); + let allocs = get_allocations(&env, "Allocations"); + let enforce_allocs = get_enforce_allocs(&env); let c = LispCircuit { params: vec![], - allocs: vec![], - alloc_inputs: vec![], - constraints: vec![], + allocs: allocs.as_ref().clone(), + alloc_inputs: allocs_input.as_ref().clone(), + constraints: enforce_allocs, env: env.clone(), }; // TODO move to another fn @@ -538,8 +538,8 @@ pub fn prove(_ast: MalVal, env: Env) -> MalRet { let params = { let c = LispCircuit { params: vec![], - allocs: vec![], - alloc_inputs: vec![], + allocs: FnvHashMap::default(), + alloc_inputs: FnvHashMap::default(), constraints: vec![], env: env.clone(), }; @@ -548,8 +548,8 @@ pub fn prove(_ast: MalVal, env: Env) -> MalRet { let circuit = LispCircuit { params: vec![], - allocs: vec![], - alloc_inputs: vec![], + allocs: FnvHashMap::default(), + alloc_inputs: FnvHashMap::default(), constraints: vec![], env: env.clone(), }; diff --git a/lisp/types.rs b/lisp/types.rs index c993ec381..8c3c91963 100644 --- a/lisp/types.rs +++ b/lisp/types.rs @@ -28,9 +28,9 @@ pub struct EnforceAllocation { #[derive(Debug, Clone)] pub struct LispCircuit { pub params: Vec>, - pub allocs: Vec>, - pub alloc_inputs: Vec>, - pub constraints: Vec>, + pub allocs: FnvHashMap, + pub alloc_inputs: FnvHashMap, + pub constraints: Vec, pub env: Env, }