diff --git a/phase2/circuit.circom b/phase2/circuit.circom index ade4725..d77beb0 100644 --- a/phase2/circuit.circom +++ b/phase2/circuit.circom @@ -1,15 +1,17 @@ template Num2Bits(n) { signal input in; + signal intermediate[n]; signal output out[n]; var lc1=0; for (var i = 0; i> i) & 1; out[i] * (out[i] -1 ) === 0; + intermediate[i] <== out[i] * out[i]; lc1 += out[i] * 2**i; } lc1 === in; } -component main = Num2Bits(253); \ No newline at end of file +component main = Num2Bits(253); diff --git a/phase2/src/utils.rs b/phase2/src/utils.rs index 243f2b6..2108401 100644 --- a/phase2/src/utils.rs +++ b/phase2/src/utils.rs @@ -37,6 +37,9 @@ pub fn same_ratio( 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) } diff --git a/powersoftau/src/utils.rs b/powersoftau/src/utils.rs index 8f032c6..f0cfba0 100644 --- a/powersoftau/src/utils.rs +++ b/powersoftau/src/utils.rs @@ -152,6 +152,9 @@ pub fn same_ratio>( 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) } diff --git a/powersoftau/test.sh b/powersoftau/test.sh index 0cdc5ec..a1452dd 100755 --- a/powersoftau/test.sh +++ b/powersoftau/test.sh @@ -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