Skip to content

Commit

Permalink
chore: update rust version in nix, fix clippy and typos (#152)
Browse files Browse the repository at this point in the history
* update rust version in nixshell, fix ci

* fix all clippy

* add typos check in precommit
  • Loading branch information
alxiong committed Aug 26, 2024
1 parent ebe240a commit dc194f8
Show file tree
Hide file tree
Showing 21 changed files with 137 additions and 82 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
members = [
"arithmetic",
"hyperplonk",
Expand Down
8 changes: 0 additions & 8 deletions arithmetic/src/univariate_polynomial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ mod test {

#[test]
fn test_build_l_with_suffix() -> Result<(), ArithErrors> {
test_build_l_with_suffix_helper::<Fr>()
}

fn test_build_l_with_suffix_helper<F: PrimeField>() -> Result<(), ArithErrors> {
// point 1 is [1, 2]
let point1 = vec![Fr::from(1u64), Fr::from(2u64)];

Expand Down Expand Up @@ -228,10 +224,6 @@ mod test {

#[test]
fn test_build_l() -> Result<(), ArithErrors> {
test_build_l_helper::<Fr>()
}

fn test_build_l_helper<F: PrimeField>() -> Result<(), ArithErrors> {
// point 1 is [1, 2]
let point1 = vec![Fr::from(1u64), Fr::from(2u64)];

Expand Down
5 changes: 3 additions & 2 deletions arithmetic/src/virtual_polynomial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl<F: PrimeField> VirtualPolynomial<F> {
aux_info: VPAuxInfo {
max_degree: 0,
num_variables,
phantom: PhantomData::default(),
phantom: PhantomData,
},
products: Vec::new(),
flattened_ml_extensions: Vec::new(),
Expand All @@ -118,7 +118,7 @@ impl<F: PrimeField> VirtualPolynomial<F> {
// The max degree is the max degree of any individual variable
max_degree: 1,
num_variables: mle.num_vars,
phantom: PhantomData::default(),
phantom: PhantomData,
},
// here `0` points to the first polynomial of `flattened_ml_extensions`
products: vec![(coefficient, vec![0])],
Expand Down Expand Up @@ -174,6 +174,7 @@ impl<F: PrimeField> VirtualPolynomial<F> {
/// Multiple the current VirtualPolynomial by an MLE:
/// - add the MLE to the MLE list;
/// - multiple each product by MLE and its coefficient.
///
/// Returns an error if the MLE has a different `num_vars` from self.
pub fn mul_by_mle(
&mut self,
Expand Down
4 changes: 2 additions & 2 deletions bench_results/plot_spartan
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set logscale y
set xrange [9:20]
# set title font ",10"
# set key title "Proving time"
set xlabel "log \# constraits"
set xlabel "log \# constraints"
set ylabel 'time (sec)'
# set xtics (4,8,16,32,64)
plot spartan using 1:2 w lp t "spartan",\
Expand Down Expand Up @@ -48,7 +48,7 @@ set grid
set xrange [9:20]
set title font ",10"
# set key title "Proving time"
set xlabel "log \# constraits"
set xlabel "log \# constraints"
set ylabel 'ratio '
# set xtics (4,8,16,32,64)
plot ratio using 1:6 w lp t "Jellyfish/Hyperplonk",\
Expand Down
118 changes: 80 additions & 38 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,22 @@
entry = "cargo sort -w";
pass_filenames = false;
};
spell-check = {
enable = true;
description = "Spell check";
entry = "typos";
pass_filenames = false;
};
};
};
};
devShell = mkShell {
buildInputs = [
argbash
openssl
pkgconfig
pkg-config
git
typos

stableToolchain
nightlyToolchain
Expand Down
3 changes: 3 additions & 0 deletions hyperplonk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ where
/// Inputs:
/// - `index`: HyperPlonk index
/// - `pcs_srs`: Polynomial commitment structured reference string
///
/// Outputs:
/// - The HyperPlonk proving key, which includes the preprocessed
/// polynomials.
Expand All @@ -54,6 +55,7 @@ where
/// - `pk`: circuit proving key
/// - `pub_input`: online public input
/// - `witness`: witness assignment
///
/// Outputs:
/// - The HyperPlonk SNARK proof.
fn prove(
Expand All @@ -68,6 +70,7 @@ where
/// - `vk`: verifying key
/// - `pub_input`: online public input
/// - `proof`: HyperPlonk SNARK proof challenges
///
/// Outputs:
/// - Return a boolean on whether the verification is successful
fn verify(
Expand Down
13 changes: 7 additions & 6 deletions hyperplonk/src/snark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,14 @@ where
/// - `pk`: circuit proving key
/// - `pub_input`: online public input of length 2^\ell
/// - `witness`: witness assignment of length 2^n
///
/// Outputs:
/// - The HyperPlonk SNARK proof.
///
/// Steps:
///
/// 1. Commit Witness polynomials `w_i(x)` and append commitment to
/// transcript
/// transcript
///
/// 2. Run ZeroCheck on
///
Expand All @@ -130,7 +131,7 @@ where
/// in vanilla plonk, and obtain a ZeroCheckSubClaim
///
/// 3. Run permutation check on `\{w_i(x)\}` and `permutation_oracle`, and
/// obtain a PermCheckSubClaim.
/// obtain a PermCheckSubClaim.
///
/// 4. Generate evaluations and corresponding proofs
/// - 4.1. (deferred) batch opening prod(x) at
Expand Down Expand Up @@ -363,6 +364,7 @@ where
/// - `vk`: verification key
/// - `pub_input`: online public input
/// - `proof`: HyperPlonk SNARK proof
///
/// Outputs:
/// - Return a boolean on whether the verification is successful
///
Expand Down Expand Up @@ -426,8 +428,7 @@ where
let pi_eval = proof.batch_openings.f_i_eval_at_point_i.last().unwrap();

// =======================================================================
// 1. Verify zero_check_proof on
// `f(q_0(x),...q_l(x), w_0(x),...w_d(x))`
// 1. Verify zero_check_proof on `f(q_0(x),...q_l(x), w_0(x),...w_d(x))`
//
// where `f` is the constraint polynomial i.e.,
//
Expand All @@ -440,7 +441,7 @@ where
let zero_check_aux_info = VPAuxInfo::<E::ScalarField> {
max_degree: vk.params.gate_func.degree(),
num_variables: num_vars,
phantom: PhantomData::default(),
phantom: PhantomData,
};
// push witness to transcript
for w_com in proof.witness_commits.iter() {
Expand Down Expand Up @@ -474,7 +475,7 @@ where
// Prod(x) has a max degree of witnesses.len() + 1
max_degree: proof.witness_commits.len() + 1,
num_variables: num_vars,
phantom: PhantomData::default(),
phantom: PhantomData,
};
let perm_check_sub_claim = <Self as PermutationCheck<E, PCS>>::verify(
&proof.perm_check_proof,
Expand Down
2 changes: 1 addition & 1 deletion hyperplonk/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub(crate) fn prover_sanity_check<F: PrimeField>(

if pub_input.len() > params.num_constraints {
return Err(HyperPlonkErrors::InvalidProver(format!(
"Public input length {} is greater than num constraits {}",
"Public input length {} is greater than num constraints {}",
pub_input.len(),
params.num_pub_input
)));
Expand Down
Loading

0 comments on commit dc194f8

Please sign in to comment.