Replace bits() fn with BITS const

This commit is contained in:
wborgeaud 2021-12-13 16:46:49 +01:00
parent aed4de0293
commit 920d5995c7
3 changed files with 3 additions and 7 deletions

View File

@ -59,6 +59,7 @@ pub trait Field:
/// Generator of a multiplicative subgroup of order `2^TWO_ADICITY`.
const POWER_OF_TWO_GENERATOR: Self;
/// The bit length of the field order.
const BITS: usize;
fn order() -> BigUint;
@ -407,11 +408,6 @@ pub trait Field:
pub trait PrimeField: Field<PrimeField = Self> {
const ORDER: u64;
/// The number of bits required to encode any field element.
fn bits() -> usize {
bits_u64(Self::NEG_ONE.to_canonical_u64())
}
fn to_canonical_u64(&self) -> u64;
fn to_noncanonical_u64(&self) -> u64;

View File

@ -338,7 +338,7 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
// verify that this has a negligible impact on soundness error.
Self::assert_noncanonical_indices_ok(&common_data.config);
let x_index = challenger.get_challenge(self);
let mut x_index_bits = self.low_bits(x_index, n_log, F::bits());
let mut x_index_bits = self.low_bits(x_index, n_log, F::BITS);
let cap_index =
self.le_sum(x_index_bits[x_index_bits.len() - common_data.config.cap_height..].iter());

View File

@ -24,7 +24,7 @@ impl<const B: usize> BaseSumGate<B> {
}
pub fn new_from_config<F: PrimeField>(config: &CircuitConfig) -> Self {
let num_limbs = F::bits().min(config.num_routed_wires - Self::START_LIMBS);
let num_limbs = F::BITS.min(config.num_routed_wires - Self::START_LIMBS);
Self::new(num_limbs)
}