Introduce mul_by_inverse_unchecked, and use it (#75)

This commit is contained in:
Pratyush Mishra
2021-07-15 16:39:34 -07:00
committed by GitHub
parent 65faa3e699
commit b6e7e94521
7 changed files with 126 additions and 67 deletions

View File

@@ -14,15 +14,31 @@ pub mod vanishing_poly;
/// Native code corresponds to `ark-poly::univariate::domain::radix2`, but `ark-poly` only supports
/// subgroup for now.
///
/// TODO: support cosets in `ark-poly`.
// TODO: support cosets in `ark-poly`.
pub struct Radix2DomainVar<F: PrimeField> {
/// generator of subgroup g
pub gen: F,
/// index of the quotient group (i.e. the `offset`)
pub offset: FpVar<F>,
offset: FpVar<F>,
/// dimension of evaluation domain
pub dim: u64,
}
impl<F: PrimeField> Radix2DomainVar<F> {
/// Construct an evaluation domain with the given offset.
pub fn new(gen: F, dimension: u64, offset: FpVar<F>) -> Result<Self, SynthesisError> {
offset.enforce_not_equal(&FpVar::zero())?;
Ok(Self {
gen,
offset,
dim: dimension,
})
}
/// What is the offset of `self`?
pub fn offset(&self) -> &FpVar<F> {
&self.offset
}
}
impl<F: PrimeField> EqGadget<F> for Radix2DomainVar<F> {
fn is_eq(&self, other: &Self) -> Result<Boolean<F>, SynthesisError> {