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

Lagrange basis aurora speedup2 #30

Draft
wants to merge 13 commits into
base: lagrange_basis_aurora_speedup2
Choose a base branch
from
7 changes: 4 additions & 3 deletions libiop/protocols/encoded/lincheck/basic_lincheck_aux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ class multi_lincheck_virtual_oracle : public virtual_oracle<FieldT> {
lagrange_polynomial<FieldT> p_alpha_;
std::vector<FieldT> p_alpha_evals_;
std::vector<FieldT> p_alpha_ABC_evals_;
vanishing_polynomial<FieldT> vd_vp_;
vanishing_polynomial<FieldT> cd_vp_;
vanishing_polynomial<FieldT> variable_domain_vanishing_polynomial_;
vanishing_polynomial<FieldT> constraint_domain_vanishing_polynomial_;

std::shared_ptr<lagrange_cache<FieldT> > lagrange_coefficients_cache_;
public:
multi_lincheck_virtual_oracle(
Expand All @@ -82,4 +83,4 @@ class multi_lincheck_virtual_oracle : public virtual_oracle<FieldT> {

#include "libiop/protocols/encoded/lincheck/basic_lincheck_aux.tcc"

#endif // LIBIOP_PROTOCOLS_ENCODED_LINCHECK_BASIC_LINCHECK_AUX_HPP_
#endif // LIBIOP_PROTOCOLS_ENCODED_LINCHECK_BASIC_LINCHECK_AUX_HPP_
34 changes: 19 additions & 15 deletions libiop/protocols/encoded/lincheck/basic_lincheck_aux.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ void multi_lincheck_virtual_oracle<FieldT>::set_challenge(const FieldT &alpha, c

enter_block("multi_lincheck compute random polynomial evaluations");

/* Set alpha polynomial, and its evaluations */
/* Set alpha polynomial, variable and constraint domain polynomials, and their evaluations */
this->p_alpha_ = lagrange_polynomial<FieldT>(alpha, this->constraint_domain_);
this->p_alpha_evals_ = this->p_alpha_.evaluations_over_field_subset(this->constraint_domain_);
this->vd_vp_ = vanishing_polynomial<FieldT>(this->variable_domain_);
this->cd_vp_ = vanishing_polynomial<FieldT>(this->constraint_domain_);
this->variable_domain_vanishing_polynomial_ = vanishing_polynomial<FieldT>(this->variable_domain_);
this->constraint_domain_vanishing_polynomial_ = vanishing_polynomial<FieldT>(this->constraint_domain_);
leave_block("multi_lincheck compute random polynomial evaluations");

/* Set p_alpha_ABC_evals */
Expand Down Expand Up @@ -94,24 +94,28 @@ std::shared_ptr<std::vector<FieldT>> multi_lincheck_virtual_oracle<FieldT>::eval
* [TODO: cite Succinct Aurora] instead of powers of alpha. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change that citation to be [BCGGRS19]?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err, no the original citation was right. I meant can you change the TODO haha

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err, no the original citation was right. I meant can you change the TODO haha

Oh my bad, yeah will be fixed in upcoming commit.

/* Compute p_alpha_prime. */
std::vector<FieldT> p_alpha_prime_over_codeword_domain;
std::vector<FieldT> vd_vp_evaluations;
std::vector<FieldT> cd_vp_evaluations;


/* If |variable_domain| > |constraint_domain|, we multiply the Lagrange sampled
polynomial by Z_{variable_domain}*Z_{constraint_domain}^-1 */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lagrange sampled polynomial -> Lagrange sampled polynomial (p_alpha_prime)

if (this->variable_domain_.num_elements() > this->constraint_domain_.num_elements()){
if (this->variable_domain_.num_elements() < this->constraint_domain_.num_elements()){
p_alpha_prime_over_codeword_domain =
this->p_alpha_.evaluations_over_field_subset(this->codeword_domain_);
}else{
/* inverses of the evaluations of constraint domain polynomial */
std::vector<FieldT> constraint_domain_vanishing_polynomial_inverses;
std::vector<FieldT> variable_domain_vanishing_polynomial_evaluations;
p_alpha_prime_over_codeword_domain = this->p_alpha_.evaluations_over_field_subset(this->codeword_domain_);

vd_vp_evaluations = this->vd_vp_.evaluations_over_field_subset(this->codeword_domain_);
cd_vp_evaluations = this->cd_vp_.evaluations_over_field_subset(this->codeword_domain_);
variable_domain_vanishing_polynomial_evaluations = this->variable_domain_vanishing_polynomial_
.evaluations_over_field_subset(this->codeword_domain_);
constraint_domain_vanishing_polynomial_inverses = batch_inverse(this->constraint_domain_vanishing_polynomial_
.evaluations_over_field_subset(this->codeword_domain_));

for (int i = 0; i < vd_vp_evaluations.size(); i++)
p_alpha_prime_over_codeword_domain[i] *= vd_vp_evaluations[i] * cd_vp_evaluations[i].inverse();
for (int i = 0; i < variable_domain_vanishing_polynomial_evaluations.size(); i++)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor note, can you put the following line of code in a { } block? Consistency with this sort of thing makes it easier to review the final code base. Hope to integrate linting soon, so there will be an automatic check for this sort of thing.

p_alpha_prime_over_codeword_domain[i] *= variable_domain_vanishing_polynomial_evaluations[i]
* constraint_domain_vanishing_polynomial_inverses[i];

}else{
p_alpha_prime_over_codeword_domain =
this->p_alpha_.evaluations_over_field_subset(this->codeword_domain_);
}

/* p_{alpha}^2 in [BCRSVW18] */
Expand Down Expand Up @@ -165,8 +169,8 @@ FieldT multi_lincheck_virtual_oracle<FieldT>::evaluation_at_point(

if (this->variable_domain_.num_elements() > this->constraint_domain_.num_elements())
FieldT p_alpha_prime_X = this->p_alpha_.evaluation_at_point(evaluation_point) *
this->vd_vp_.evaluation_at_point(evaluation_point) *
this->cd_vp_.evaluation_at_point(evaluation_point).inverse();
this->variable_domain_vanishing_polynomial_.evaluation_at_point(evaluation_point) *
this->constraint_domain_vanishing_polynomial_.evaluation_at_point(evaluation_point).inverse();
else
FieldT p_alpha_prime_X = this->p_alpha_.evaluation_at_point(evaluation_point);

Expand Down