adds check_ratio tests and modifies tests to accomodate it

This commit is contained in:
Kobi Gurkan 2020-04-27 14:22:31 +03:00 committed by poma
parent 72a2111e03
commit d79ba70c89
No known key found for this signature in database
GPG Key ID: BA20CB01FE165657
4 changed files with 10 additions and 3 deletions

@ -1,11 +1,13 @@
template Num2Bits(n) {
signal input in;
signal intermediate[n];
signal output out[n];
var lc1=0;
for (var i = 0; i<n; i++) {
out[i] <-- (in >> i) & 1;
out[i] * (out[i] -1 ) === 0;
intermediate[i] <== out[i] * out[i];
lc1 += out[i] * 2**i;
}

@ -37,6 +37,9 @@ pub fn same_ratio<G1: CurveAffine>(
g2: (G1::Pair, G1::Pair)
) -> bool
{
if g1.0.is_zero() || g1.1.is_zero() || g2.0.is_zero() || g2.1.is_zero() {
panic!(format!("none of the inputs should be zero: {}, {}, {}, {}", g1.0, g1.1, g2.0, g2.1));
}
g1.0.pairing_with(&g2.1) == g1.1.pairing_with(&g2.0)
}

@ -152,6 +152,9 @@ pub fn same_ratio<E: Engine, G1: CurveAffine<Engine = E, Scalar = E::Fr>>(
g1: (G1, G1),
g2: (G1::Pair, G1::Pair),
) -> bool {
if g1.0.is_zero() || g1.1.is_zero() || g2.0.is_zero() || g2.1.is_zero() {
panic!(format!("none of the inputs should be zero: {}, {}, {}, {}", g1.0, g1.1, g2.0, g2.1));
}
g1.0.pairing_with(&g2.1) == g1.1.pairing_with(&g2.0)
}

@ -24,5 +24,4 @@ cargo run --release --bin verify_transform_constrained challenge3 response3 chal
cargo run --release --bin beacon_constrained challenge4 response4 $SIZE $BATCH 0000000000000000000a558a61ddc8ee4e488d647a747fe4dcc362fe2026c620
cargo run --release --bin verify_transform_constrained challenge4 response4 challenge5 $SIZE $BATCH
cat response1 response2 response3 response4 > transcript
cargo run --release --bin verify transcript $SIZE $BATCH
cargo run --release --bin prepare_phase2 response4 $SIZE $BATCH