From 920d5995c7eb04e8b8174a17a1829ecda4e9188d Mon Sep 17 00:00:00 2001 From: wborgeaud Date: Mon, 13 Dec 2021 16:46:49 +0100 Subject: [PATCH] Replace `bits()` fn with `BITS` const --- src/field/field_types.rs | 6 +----- src/fri/recursive_verifier.rs | 2 +- src/gates/base_sum.rs | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/field/field_types.rs b/src/field/field_types.rs index a3affc13..b6d9e700 100644 --- a/src/field/field_types.rs +++ b/src/field/field_types.rs @@ -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 { 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; diff --git a/src/fri/recursive_verifier.rs b/src/fri/recursive_verifier.rs index c2684725..dc4214b5 100644 --- a/src/fri/recursive_verifier.rs +++ b/src/fri/recursive_verifier.rs @@ -338,7 +338,7 @@ impl, const D: usize> CircuitBuilder { // 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()); diff --git a/src/gates/base_sum.rs b/src/gates/base_sum.rs index 2ab5345b..7ea235fa 100644 --- a/src/gates/base_sum.rs +++ b/src/gates/base_sum.rs @@ -24,7 +24,7 @@ impl BaseSumGate { } pub fn new_from_config(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) }