Skip to content

Commit

Permalink
doc: fix a few nits (#160)
Browse files Browse the repository at this point in the history
* refactor: rename powers -> squares

- Renamed the `powers` method to `squares` in `PowPolynomial` struct within `src/spartan/polys/power.rs` and changed its visibility level.

* fix: comment

* fix: comment of batch
  • Loading branch information
huitseeker committed Dec 8, 2023
1 parent 66b969e commit 4ece8df
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/spartan/batched.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ where
// Generate tau polynomial corresponding to eq(τ, τ², τ⁴ , …)
// for a random challenge τ
let tau = transcript.squeeze(b"t")?;
let all_taus = PowPolynomial::powers(&tau, num_rounds_x_max);
let all_taus = PowPolynomial::squares(&tau, num_rounds_x_max);

let polys_tau = num_rounds_x
.iter()
Expand Down
2 changes: 1 addition & 1 deletion src/spartan/batched_ppsnark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ where
// Sample new random variable for eq polynomial
let rho = transcript.squeeze(b"r")?;
let N_max = N.iter().max().unwrap();
let all_rhos = PowPolynomial::powers(&rho, N_max.log_2());
let all_rhos = PowPolynomial::squares(&rho, N_max.log_2());

let instances = zip_with!(
(
Expand Down
10 changes: 8 additions & 2 deletions src/spartan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub struct PolyEvalWitness<E: Engine> {
}

impl<E: Engine> PolyEvalWitness<E> {
/// Given [Pᵢ] and [sᵢ], compute P = ∑ᵢ sᵢ⋅Pᵢ
/// Given [Pᵢ] and s, compute P = ∑ᵢ sⁱ⋅Pᵢ
///
/// # Details
///
Expand Down Expand Up @@ -154,7 +154,13 @@ impl<E: Engine> PolyEvalWitness<E> {
PolyEvalWitness { p }
}

// This method panics unless all vectors in p_vec are of the same length
/// Given a set of polynomials \[Pᵢ\] and a scalar `s`, this method computes the weighted sum
/// of the polynomials, where each polynomial Pᵢ is scaled by sⁱ. The method handles polynomials
/// of different sizes by padding smaller ones with zeroes up to the size of the largest polynomial.
///
/// # Panics
///
/// This method panics if the polynomials in `p_vec` are not all of the same length.
fn batch(p_vec: &[&Vec<E::Scalar>], s: &E::Scalar) -> PolyEvalWitness<E> {
p_vec
.iter()
Expand Down
4 changes: 2 additions & 2 deletions src/spartan/polys/power.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl<Scalar: PrimeField> PowPolynomial<Scalar> {
/// Creates a new `PowPolynomial` from a Scalars `t`.
pub fn new(t: &Scalar, ell: usize) -> Self {
// t_pow = [t^{2^0}, t^{2^1}, ..., t^{2^{ell-1}}]
let t_pow = Self::powers(t, ell);
let t_pow = Self::squares(t, ell);

PowPolynomial {
eq: EqPolynomial::new(t_pow),
Expand All @@ -27,7 +27,7 @@ impl<Scalar: PrimeField> PowPolynomial<Scalar> {

/// Create powers the following powers of `t`:
/// [t^{2^0}, t^{2^1}, ..., t^{2^{ell-1}}]
pub(crate) fn powers(t: &Scalar, ell: usize) -> Vec<Scalar> {
pub(in crate::spartan) fn squares(t: &Scalar, ell: usize) -> Vec<Scalar> {
successors(Some(*t), |p: &Scalar| Some(p.square()))
.take(ell)
.collect::<Vec<_>>()
Expand Down

0 comments on commit 4ece8df

Please sign in to comment.