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

silence warnings, autofix lints #2

Closed
wants to merge 1 commit 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
28 changes: 17 additions & 11 deletions halo2_proofs/src/protostar/error_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,15 +436,21 @@ pub fn evaluated_challenge_powers<F: Field>(
}

/// Computes [1, v, v^2, ..., v^max_degee]
fn powers_of<F: Field>(v: &F, max_degee: usize) -> Vec<F> {
let mut powers = Vec::with_capacity(max_degee + 1);
let mut acc = F::ONE;
powers.push(acc);

// we need max_degee + 1 since we include v^0 = 1
for _i in 1..max_degee + 1 {
acc *= v;
powers.push(acc);
}
powers
fn powers_of<F: Field>(v: &F, max_degree: usize) -> Vec<F> {
std::iter::successors(Some(F::ONE), |&n| Some(n * v))
// we need max_degee + 1 since we include v^0 = 1
.take(max_degree + 1)
.collect()
}

#[cfg(test)]
mod test{
use super::*;
use crate::{halo2curves::pasta::Fp, plonk::sealed::SealedPhase};
#[test]
fn test_powers_of(){
let v = Fp::from(2u64);
let expect: Vec<Fp> = [1,2,4,8,16,32].into_iter().map(Fp::from).collect();
assert_eq!(expect, powers_of(&v, 5));
}
}
2 changes: 2 additions & 0 deletions halo2_proofs/src/protostar/shuffle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ use ff::{BatchInvert, FromUniformBytes};
use rand_core::{OsRng, RngCore};
use std::iter::{self, zip};

/// generate a random 2d array of field elements of size W x H
fn rand_2d_array<F: Field, R: RngCore, const W: usize, const H: usize>(rng: &mut R) -> [[F; H]; W] {
[(); W].map(|_| [(); H].map(|_| F::random(&mut *rng)))
}

/// randomly permute the columns 2d array `original`
fn shuffled<F: Field, R: RngCore, const W: usize, const H: usize>(
original: [[F; H]; W],
rng: &mut R,
Expand Down