fn* for zk circuit

This commit is contained in:
ada
2020-10-27 20:45:34 +01:00
parent f4fe7408cf
commit a4c863e4bb
2 changed files with 13 additions and 23 deletions

View File

@@ -263,18 +263,6 @@ fn eval(mut ast: MalVal, mut env: Env) -> MalRet {
_ => Ok(Nil),
}
}
Sym(ref a0sym) if a0sym == "zk*" => {
// TODO create zk circuit and evaluate the rest
let (a1, a2) = (l[1].clone(), l[2].clone());
Ok(MalFunc {
eval: eval,
ast: Rc::new(a2),
env: env,
params: Rc::new(a1),
is_macro: false,
meta: Rc::new(Nil),
})
}
Sym(ref a0sym) if a0sym == "fn*" => {
let (a1, a2) = (l[1].clone(), l[2].clone());
Ok(MalFunc {
@@ -311,8 +299,10 @@ fn eval(mut ast: MalVal, mut env: Env) -> MalRet {
ast = a.clone();
continue 'tco;
}
_ => { println!("{:?}", el);
error("attempt to call non-function")},
_ => {
Ok(Nil)
//error("attempt to call non-function")
},
}
}
_ => error("expected a list"),

View File

@@ -1,18 +1,18 @@
(def! circuit (zk* [x] (
(def! circuit (fn* [x] (
(def! bits (unpack-bits x 256))
(map (fn* [b] (println
(map (fn* [b] (println b
'(add lc0 one)
'(sub b)
'(add lc1 x)
'enforce)
) bits)
(map (fn* [b] (println '(add lc0 b)
'double-coeff-lc)
) bits)
(println 'reset-coeff-lc
'(sub lc0 x)
'(add lc1 one)
'enforce)
(map (fn* [b] (println b '(add lc0 b)
'double-coeff-lc)
) bits)
(println 'reset-coeff-lc
'(sub lc0 x)
'(add lc1 one)
'enforce)
)))
(def! dec "73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000000")
(circuit dec)