Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant "hiding" value from Domain state #27

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions common/src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl<F: FftField> Domains<F> {
assert_eq!(evals.len(), self.x1.size());
let evals = Evaluations::from_vec_and_domain(evals, self.x1);
let poly = evals.interpolate_by_ref();
let evals_4x = poly.evaluate_over_domain_by_ref(self.x4);
let evals_4x = self.amplify(&poly);
FieldColumn { len, poly, evals, evals_4x }
}

Expand All @@ -38,6 +38,7 @@ impl<F: FftField> Domains<F> {
}

// Amplifies the number of the evaluations of the polynomial so it can be multiplied in linear time.
#[inline(always)]
fn amplify(&self, poly: &DensePolynomial<F>) -> Evaluations<F> {
poly.evaluate_over_domain_by_ref(self.x4)
}
Expand All @@ -46,7 +47,6 @@ impl<F: FftField> Domains<F> {
#[derive(Clone)]
pub struct Domain<F: FftField> {
domains: Domains<F>,
pub hiding: bool,
pub capacity: usize,
pub not_last_row: FieldColumn<F>,
pub l_first: FieldColumn<F>,
Expand All @@ -72,7 +72,6 @@ impl<F: FftField> Domain<F> {

Self {
domains,
hiding,
capacity,
not_last_row,
l_first,
Expand All @@ -85,20 +84,21 @@ impl<F: FftField> Domain<F> {
&self,
poly: &DensePolynomial<F>,
) -> DensePolynomial<F> {
let (quotient, remainder) = if self.hiding {
let exclude_zk_rows = poly * self.zk_rows_vanishing_poly.as_ref().unwrap();
exclude_zk_rows.divide_by_vanishing_poly(self.domains.x1).unwrap() //TODO error-handling
// `divide_by_vanishing_poly` can't fail: https://github.com/arkworks-rs/algebra/pull/850
let (quotient, remainder) = if let Some(zk_rows_vanishing) = self.zk_rows_vanishing_poly.as_ref() {
let exclude_zk_rows = poly * zk_rows_vanishing;
exclude_zk_rows.divide_by_vanishing_poly(self.domains.x1)
} else {
poly.divide_by_vanishing_poly(self.domains.x1).unwrap() //TODO error-handling
};
poly.divide_by_vanishing_poly(self.domains.x1)
}.unwrap();
assert!(remainder.is_zero()); //TODO error-handling
quotient
}

pub(crate) fn column(&self, mut evals: Vec<F>, hidden: bool) -> FieldColumn<F> {
let len = evals.len();
assert!(len <= self.capacity);
if self.hiding && hidden {
if self.hiding() && hidden {
evals.resize(self.capacity, F::zero());
evals.resize_with(self.domains.x1.size(), || F::rand(&mut getrandom_or_panic::getrandom_or_panic()));
} else {
Expand All @@ -107,22 +107,31 @@ impl<F: FftField> Domain<F> {
self.domains.column_from_evals(evals, len)
}

#[inline(always)]
pub fn private_column(&self, evals: Vec<F>) -> FieldColumn<F> {
self.column(evals, true)
}

// public column
#[inline(always)]
pub fn public_column(&self, evals: Vec<F>) -> FieldColumn<F> {
self.column(evals, false)
}

#[inline(always)]
pub fn omega(&self) -> F {
self.domains.x1.group_gen()
}

#[inline(always)]
pub fn domain(&self) -> GeneralEvaluationDomain<F> {
self.domains.x1
}

#[inline(always)]
pub fn hiding(&self) -> bool {
self.zk_rows_vanishing_poly.is_some()
}
}

fn l_i<F: FftField>(i: usize, n: usize) -> Vec<F> {
Expand Down
1 change: 1 addition & 0 deletions common/src/gadgets/sw_cond_add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub struct CondAdd<F: FftField, P: AffineRepr<BaseField=F>> {
not_last: FieldColumn<F>,
// Accumulates the (conditional) rolling sum of the points
pub acc: AffineColumn<F, P>,
// Accumulated result minus the seed.
pub result: P,
}

Expand Down
2 changes: 1 addition & 1 deletion ring/src/ring_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<F: PrimeField, CS: PCS<F>, Curve: SWCurveConfig<BaseField=F>> RingVerifier<
);
let seed = self.piop_params.seed;
let seed_plus_result = (seed + result).into_affine();
let domain_eval = EvaluatedDomain::new(self.piop_params.domain.domain(), challenges.zeta, self.piop_params.domain.hiding);
let domain_eval = EvaluatedDomain::new(self.piop_params.domain.domain(), challenges.zeta, self.piop_params.domain.hiding());

let piop = PiopVerifier::init(
domain_eval,
Expand Down
Loading