use map; and TODOs

This commit is contained in:
Nicholas Ward 2021-11-02 10:54:34 -07:00
parent 1d4bb3950d
commit e838096940
3 changed files with 7 additions and 6 deletions

View File

@ -206,6 +206,7 @@ pub trait Field:
subgroup.into_iter().map(|x| x * shift).collect()
}
// TODO: move these to a new `PrimeField` trait (for all prime fields, not just 64-bit ones)
fn from_biguint(n: BigUint) -> Self;
fn to_biguint(&self) -> BigUint;

View File

@ -28,12 +28,10 @@ impl BigUintTarget {
impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
pub fn constant_biguint(&mut self, value: &BigUint) -> BigUintTarget {
let limb_values = value.to_u32_digits();
let mut limbs = Vec::new();
for i in 0..limb_values.len() {
limbs.push(U32Target(
self.constant(F::from_canonical_u32(limb_values[i])),
));
}
let limbs = limb_values
.iter()
.map(|l| self.constant(F::from_canonical_u32(l)))
.collect();
BigUintTarget { limbs }
}

View File

@ -13,6 +13,8 @@ use crate::plonk::plonk_common::{reduce_with_powers, reduce_with_powers_ext_recu
use crate::plonk::vars::{EvaluationTargets, EvaluationVars, EvaluationVarsBase};
use crate::util::{bits_u64, ceil_div_usize};
// TODO: replace/merge this gate with `ComparisonGate`.
/// A gate for checking that one value is less than or equal to another.
#[derive(Clone, Debug)]
pub struct AssertLessThanGate<F: PrimeField + Extendable<D>, const D: usize> {