From 8702b2909d5701e86573a43c88a94cfc9dd8ecaf Mon Sep 17 00:00:00 2001 From: saitima Date: Tue, 10 Dec 2024 19:37:26 +0300 Subject: [PATCH] fix(snark-wrapper): call range check with proper params --- crates/franklin-crypto/src/plonk/circuit/goldilocks/mod.rs | 6 +++++- crates/snark-wrapper/src/verifier/mod.rs | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/franklin-crypto/src/plonk/circuit/goldilocks/mod.rs b/crates/franklin-crypto/src/plonk/circuit/goldilocks/mod.rs index 9f7c22a..24b9fb2 100644 --- a/crates/franklin-crypto/src/plonk/circuit/goldilocks/mod.rs +++ b/crates/franklin-crypto/src/plonk/circuit/goldilocks/mod.rs @@ -47,6 +47,10 @@ impl Hash for GoldilocksField { } pub fn range_check_for_num_bits>(cs: &mut CS, num: &Num, num_bits: usize) -> Result<(), SynthesisError> { + range_check_for_num_bits_coarsely(cs, num, num_bits, true) +} + +pub fn range_check_for_num_bits_coarsely>(cs: &mut CS, num: &Num, num_bits: usize, coarsely: bool) -> Result<(), SynthesisError> { assert!(num_bits % 16 == 0); if let Num::Constant(value) = num { @@ -56,7 +60,7 @@ pub fn range_check_for_num_bits>(cs: &mut CS, } else { // Name of the table should be checked if let Ok(table) = cs.get_table(BITWISE_LOGICAL_OPS_TABLE_NAME) { - enforce_range_check_using_bitop_table(cs, &num.get_variable(), num_bits, table, true)?; + enforce_range_check_using_bitop_table(cs, &num.get_variable(), num_bits, table, coarsely)?; } else if >::CAN_ACCESS_NEXT_TRACE_STEP { enforce_range_check_using_naive_approach(cs, &num.get_variable(), num_bits)?; } else { diff --git a/crates/snark-wrapper/src/verifier/mod.rs b/crates/snark-wrapper/src/verifier/mod.rs index 2f46716..8c16f3a 100644 --- a/crates/snark-wrapper/src/verifier/mod.rs +++ b/crates/snark-wrapper/src/verifier/mod.rs @@ -201,9 +201,9 @@ fn aggregate_public_inputs>(cs: &mut CS, publ ); // Firstly we check that public inputs have correct size - use rescue_poseidon::franklin_crypto::plonk::circuit::goldilocks::range_check_for_num_bits; + use rescue_poseidon::franklin_crypto::plonk::circuit::goldilocks::range_check_for_num_bits_coarsely; for pi in public_inputs.iter() { - range_check_for_num_bits(cs, &pi.into_num(), 64)?; + range_check_for_num_bits_coarsely(cs, &pi.into_num(), 64, false)?; } // compute aggregated pi value