From 2662b51afdc3b5b29378b5407b636a10a537eefa Mon Sep 17 00:00:00 2001 From: Enrico Bottazzi <85900164+enricobottazzi@users.noreply.github.com> Date: Mon, 2 Oct 2023 15:08:30 +0200 Subject: [PATCH] fix: fetch `q_bits` operation --- src/chips/distribution.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/chips/distribution.rs b/src/chips/distribution.rs index 7921a99..15c2c5c 100644 --- a/src/chips/distribution.rs +++ b/src/chips/distribution.rs @@ -32,8 +32,9 @@ pub fn check_poly_from_distribution_chi_error< // The bool value of `in_range` is then enforced to be true let mut in_range_vec = Vec::with_capacity((N + 1) as usize); - // get the number of bits required to represent the modulus q - let q_bits = (Q as f64).log2().ceil() as usize; + // get the number of bits needed to represent the value of Q + let binary_representation = format!("{:b}", Q); // Convert to binary (base-2) + let q_bits = binary_representation.len(); for coeff in &a { // Check for the range [0, B] @@ -96,4 +97,4 @@ pub fn check_poly_from_distribution_chi_key