-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce hashing costs with a power polynomial in ppsnark (#248)
* use eq polynomial emulated via power polynomial, to reduce hashing costs * update version * add missing file
- Loading branch information
1 parent
fee8934
commit 5b3ce99
Showing
4 changed files
with
74 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "nova-snark" | ||
version = "0.27.0" | ||
version = "0.28.0" | ||
authors = ["Srinath Setty <[email protected]>"] | ||
edition = "2021" | ||
description = "Recursive zkSNARKs without trusted setup" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
//! This module contains the definitions of polynomial types used in the Spartan SNARK. | ||
pub mod eq; | ||
pub mod multilinear; | ||
pub(crate) mod power; | ||
pub(crate) mod univariate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
//! `PowPolynomial`: Represents multilinear extension of power polynomials | ||
use crate::spartan::polys::eq::EqPolynomial; | ||
use ff::PrimeField; | ||
|
||
/// Represents the multilinear extension polynomial (MLE) of the equality polynomial $pow(x,t)$, denoted as $\tilde{pow}(x, t)$. | ||
/// | ||
/// The polynomial is defined by the formula: | ||
/// $$ | ||
/// \tilde{power}(x, t) = \prod_{i=1}^m(1 + (t^{2^i} - 1) * x_i) | ||
/// $$ | ||
pub struct PowPolynomial<Scalar: PrimeField> { | ||
t_pow: Vec<Scalar>, | ||
eq: EqPolynomial<Scalar>, | ||
} | ||
|
||
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 mut t_pow = vec![Scalar::ONE; ell]; | ||
t_pow[0] = *t; | ||
for i in 1..ell { | ||
t_pow[i] = t_pow[i - 1].square(); | ||
} | ||
|
||
PowPolynomial { | ||
t_pow: t_pow.clone(), | ||
eq: EqPolynomial::new(t_pow), | ||
} | ||
} | ||
|
||
/// Evaluates the `PowPolynomial` at a given point `rx`. | ||
/// | ||
/// This function computes the value of the polynomial at the point specified by `rx`. | ||
/// It expects `rx` to have the same length as the internal vector `t_pow`. | ||
/// | ||
/// Panics if `rx` and `t_pow` have different lengths. | ||
pub fn evaluate(&self, rx: &[Scalar]) -> Scalar { | ||
self.eq.evaluate(rx) | ||
} | ||
|
||
pub fn coordinates(&self) -> Vec<Scalar> { | ||
self.t_pow.clone() | ||
} | ||
|
||
/// Evaluates the `PowPolynomial` at all the `2^|t_pow|` points in its domain. | ||
/// | ||
/// Returns a vector of Scalars, each corresponding to the polynomial evaluation at a specific point. | ||
pub fn evals(&self) -> Vec<Scalar> { | ||
self.eq.evals() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters