From c3c150fcd07f424af7919bf7831dd27b8ecadf46 Mon Sep 17 00:00:00 2001 From: ada Date: Tue, 2 Feb 2021 10:55:05 +0100 Subject: [PATCH] added enforce for left, right and output --- lisp/types.rs | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/lisp/types.rs b/lisp/types.rs index eca40c234..1f0f90d41 100644 --- a/lisp/types.rs +++ b/lisp/types.rs @@ -77,14 +77,41 @@ impl Circuit for LispCircuit { let mut output = bellman::LinearCombination::::zero(); for values in alloc_value.left.iter() { let (a, b) = values; - println!("{:?} {:?}", a, variables.get(a)); - println!("{:?} {:?}", b, variables.get(b)); - let val_a = variables.get(a).unwrap(); - let val_b = variables.get(b).unwrap(); + let mut val_b = CS::one(); + if b != "cs::one" { + val_b = *variables.get(b).unwrap(); + } if a == "scalar::one" { - // val_a = coeff; + left = left + (coeff, val_b); + } else if a == "scalar::one::neg" { + left = left + (coeff.neg(), val_b); + } + } + + for values in alloc_value.right.iter() { + let (a, b) = values; + let mut val_b = CS::one(); + if b != "cs::one" { + val_b = *variables.get(b).unwrap(); + } + if a == "scalar::one" { + right = right + (coeff, val_b); + } else if a == "scalar::one::neg" { + right = right + (coeff.neg(), val_b); + } + } + + for values in alloc_value.output.iter() { + let (a, b) = values; + let mut val_b = CS::one(); + if b != "cs::one" { + val_b = *variables.get(b).unwrap(); + } + if a == "scalar::one" { + output = output + (coeff, val_b); + } else if a == "scalar::one::neg" { + output = output + (coeff.neg(), val_b); } - left = left + (coeff, *val_b); } cs.enforce(