remove unreachable variant, add comments to snark verification tests
This commit is contained in:
parent
878faf2ba3
commit
6f0821f129
4 changed files with 23 additions and 5 deletions
|
@ -1,5 +1,11 @@
|
||||||
from "EMBED" import snark_verify_bls12_377
|
from "EMBED" import snark_verify_bls12_377
|
||||||
|
|
||||||
|
// Verifies a proof with 1 public input (0 inputs + 1 output)
|
||||||
|
// Circuit used in this test:
|
||||||
|
//
|
||||||
|
// def main() -> field:
|
||||||
|
// return 1
|
||||||
|
|
||||||
def main(private field[1] inputs, private field[8] proof, private field[20] vk) -> bool:
|
def main(private field[1] inputs, private field[8] proof, private field[20] vk) -> bool:
|
||||||
bool result = snark_verify_bls12_377(inputs, proof, vk)
|
bool result = snark_verify_bls12_377(inputs, proof, vk)
|
||||||
return result
|
return result
|
|
@ -1,5 +1,11 @@
|
||||||
from "EMBED" import snark_verify_bls12_377
|
from "EMBED" import snark_verify_bls12_377
|
||||||
|
|
||||||
|
// Verifies a proof with 2 public inputs (1 input + 1 output)
|
||||||
|
// Circuit used in this test:
|
||||||
|
//
|
||||||
|
// def main(field a) -> field:
|
||||||
|
// return a * a
|
||||||
|
|
||||||
def main(private field[2] inputs, private field[8] proof, private field[22] vk) -> bool:
|
def main(private field[2] inputs, private field[8] proof, private field[22] vk) -> bool:
|
||||||
bool result = snark_verify_bls12_377(inputs, proof, vk)
|
bool result = snark_verify_bls12_377(inputs, proof, vk)
|
||||||
return result
|
return result
|
|
@ -1,5 +1,15 @@
|
||||||
from "EMBED" import snark_verify_bls12_377
|
from "EMBED" import snark_verify_bls12_377
|
||||||
|
|
||||||
|
// Verifies a proof with 5 public inputs (4 inputs + 1 output)
|
||||||
|
// Circuit used in this test:
|
||||||
|
//
|
||||||
|
// def main(field[4] a) -> field:
|
||||||
|
// field out = 0
|
||||||
|
// for u32 i in 0..4 do
|
||||||
|
// out = out + a[i]
|
||||||
|
// endfor
|
||||||
|
// return out
|
||||||
|
|
||||||
def main(private field[5] inputs, private field[8] proof, private field[28] vk) -> bool:
|
def main(private field[5] inputs, private field[8] proof, private field[28] vk) -> bool:
|
||||||
bool result = snark_verify_bls12_377(inputs, proof, vk)
|
bool result = snark_verify_bls12_377(inputs, proof, vk)
|
||||||
return result
|
return result
|
|
@ -58,7 +58,7 @@ pub fn generate_verify_constraints(
|
||||||
let cs_sys = ConstraintSystem::<BW6Fr>::new();
|
let cs_sys = ConstraintSystem::<BW6Fr>::new();
|
||||||
let cs = ConstraintSystemRef::new(cs_sys);
|
let cs = ConstraintSystemRef::new(cs_sys);
|
||||||
|
|
||||||
let mut rng = test_rng();
|
let mut rng = test_rng(); // has a fixed seed
|
||||||
let circuit = DefaultCircuit { public_input_size };
|
let circuit = DefaultCircuit { public_input_size };
|
||||||
|
|
||||||
let (pk, vk) = GM17Snark::circuit_specific_setup(circuit, &mut rng).unwrap();
|
let (pk, vk) = GM17Snark::circuit_specific_setup(circuit, &mut rng).unwrap();
|
||||||
|
@ -161,10 +161,6 @@ pub fn generate_verify_constraints(
|
||||||
.variable()
|
.variable()
|
||||||
.get_index_unchecked(num_instance_variables)
|
.get_index_unchecked(num_instance_variables)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
Boolean::Not(x) => x
|
|
||||||
.variable()
|
|
||||||
.get_index_unchecked(num_instance_variables)
|
|
||||||
.unwrap(),
|
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue