This commit is contained in:
ada
2020-12-29 20:30:06 +01:00
parent f89e24d286
commit 6a663cf0b7
2 changed files with 17 additions and 5 deletions

View File

@@ -300,8 +300,7 @@ fn eval(mut ast: MalVal, mut env: Env) -> MalRet {
}
Sym(ref a0sym) if a0sym == "setup" => {
let a1 = l[1].clone();
let circuit = setup(&ast, env.clone())?;
env_sets(&env, ZK_CIRCUIT_ENV_KEY, circuit);
setup(a1.clone(), env.clone())?;
eval(a1.clone(), env.clone())
}
Sym(ref a0sym) if a0sym == "prove" => {
@@ -389,7 +388,7 @@ pub fn env_circuit(mut env: Env) -> MalVal {
}
}
pub fn setup(ast: &MalVal, mut env: Env) -> MalRet {
pub fn setup(ast: MalVal, mut env: Env) -> MalRet {
println!("{:?}", ast);
// TODO get params from ast
let start = Instant::now();

View File

@@ -14,12 +14,18 @@ use crate::types::MalVal::{Atom, Bool, Func, Hash, Int, List, MalFunc, Nil, Str,
use bls12_381::Scalar;
use sapvi::{BlsStringConversion, ConstraintInstruction};
#[derive(Debug, Clone)]
pub struct Allocation {
pub symbol: String,
pub value: Scalar
}
#[derive(Debug, Clone)]
pub struct LispCircuit {
// TODO refactor to vec
pub params: Vec<Option<Scalar>>,
pub allocs: Vec<Option<Scalar>>,
pub alloc_inputs: Vec<Option<Scalar>>,
pub allocs: Vec<Option<Allocation>>,
pub alloc_inputs: Vec<Option<Allocation>>,
pub constraints: Vec<Option<Scalar>>,
pub env: Env,
}
@@ -29,6 +35,13 @@ impl Circuit<bls12_381::Scalar> for LispCircuit {
self,
cs: &mut CS,
) -> Result<(), SynthesisError> {
for alloc_value in &self.allocs {
// let var = cs.alloc(|| "private alloc", ||)?;
// TODO use env
println!("{:?}", alloc_value);
}
Ok(())
}
}