added enforce for left, right and output

This commit is contained in:
ada
2021-02-02 10:55:05 +01:00
parent 94208ee338
commit c3c150fcd0

View File

@@ -77,14 +77,41 @@ impl Circuit<bls12_381::Scalar> for LispCircuit {
let mut output = bellman::LinearCombination::<Scalar>::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(