Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
Velaciela committed Oct 8, 2023
1 parent 233dbc6 commit 7675aaf
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 83 deletions.
73 changes: 21 additions & 52 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion halo2_proofs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ blake2b_simd = "1"
sha3 = "0.9.1"
subtle = "2.3"
cfg-if = "0.1"
poseidon = { git = "https://github.com/scroll-tech/poseidon.git", branch = "scroll-dev-0220" }
poseidon = { git = "https://github.com/privacy-scaling-explorations/poseidon.git", tag = "v2023_04_20" }
num-integer = "0.1"
num-bigint = { version = "0.4", features = ["rand"] }

Expand Down
12 changes: 6 additions & 6 deletions halo2_proofs/src/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ fn serial_split_fft<Scalar: Field, G: FftGroup<Scalar>>(

let mut k = 0;
while k < n {
let mut w = G::Scalar::ONE;
let mut w = Scalar::ONE;
for j in 0..m {
let mut t = a[(k + j + m) as usize];
t *= &w;
Expand Down Expand Up @@ -293,7 +293,7 @@ fn split_radix_fft<Scalar: Field, G: FftGroup<Scalar>>(

// we use out-place bitreverse here, split_m <= num_threads, so the buffer spase is small
// and it's is good for data locality
let mut t1 = vec![G::Scalar::ZERO; split_m];
let mut t1 = vec![G::identity(); split_m];

Check failure on line 296 in halo2_proofs/src/arithmetic.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

no function or associated item named `identity` found for type parameter `G` in the current scope

error[E0599]: no function or associated item named `identity` found for type parameter `G` in the current scope --> halo2_proofs/src/arithmetic.rs:296:26 | 283 | fn split_radix_fft<Scalar: Field, G: FftGroup<Scalar>>( | - function or associated item `identity` not found for this type parameter ... 296 | let mut t1 = vec![G::identity(); split_m]; | ^^^^^^^^ function or associated item not found in `G` | = help: items from traits can only be used if the type parameter is bounded by the trait help: the following traits define an item `identity`, perhaps you need to restrict type parameter `G` with one of them: | 283 | fn split_radix_fft<Scalar: Field, G: FftGroup<Scalar> + group::Group>( | ++++++++++++++ 283 | fn split_radix_fft<Scalar: Field, G: FftGroup<Scalar> + group::cofactor::CofactorCurveAffine>( | ++++++++++++++++++++++++++++++++++++++ 283 | fn split_radix_fft<Scalar: Field, G: FftGroup<Scalar> + group::prime::PrimeCurveAffine>( | ++++++++++++++++++++++++++++++++

Check failure on line 296 in halo2_proofs/src/arithmetic.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

no function or associated item named `identity` found for type parameter `G` in the current scope

error[E0599]: no function or associated item named `identity` found for type parameter `G` in the current scope --> halo2_proofs/src/arithmetic.rs:296:26 | 283 | fn split_radix_fft<Scalar: Field, G: FftGroup<Scalar>>( | - function or associated item `identity` not found for this type parameter ... 296 | let mut t1 = vec![G::identity(); split_m]; | ^^^^^^^^ function or associated item not found in `G` | = help: items from traits can only be used if the type parameter is bounded by the trait help: the following traits define an item `identity`, perhaps you need to restrict type parameter `G` with one of them: | 283 | fn split_radix_fft<Scalar: Field, G: FftGroup<Scalar> + group::Group>( | ++++++++++++++ 283 | fn split_radix_fft<Scalar: Field, G: FftGroup<Scalar> + group::cofactor::CofactorCurveAffine>( | ++++++++++++++++++++++++++++++++++++++ 283 | fn split_radix_fft<Scalar: Field, G: FftGroup<Scalar> + group::prime::PrimeCurveAffine>( | ++++++++++++++++++++++++++++++++
// if unsafe code is allowed, a 10% performance improvement can be achieved
// let mut t1: Vec<G> = Vec::with_capacity(split_m as usize);
// unsafe{ t1.set_len(split_m as usize); }
Expand All @@ -310,7 +310,7 @@ fn split_radix_fft<Scalar: Field, G: FftGroup<Scalar>>(
if high_idx > 0 {
omega = omega * twiddle_lut[(1 << sparse_degree) + high_idx];
}
let mut w_m = G::Scalar::ONE;
let mut w_m = Scalar::ONE;
for i in 0..split_m {
t1[i] *= &w_m;
tmp[i] = t1[i];
Expand All @@ -329,7 +329,7 @@ pub fn generate_twiddle_lookup_table<F: Field>(

// dense
if is_lut_len_large {
let mut twiddle_lut = vec![F::zero(); (1 << log_n) as usize];
let mut twiddle_lut = vec![F::ZERO; (1 << log_n) as usize];
parallelize(&mut twiddle_lut, |twiddle_lut, start| {
let mut w_n = omega.pow_vartime([start as u64, 0, 0, 0]);
for twiddle_lut in twiddle_lut.iter_mut() {
Expand All @@ -343,7 +343,7 @@ pub fn generate_twiddle_lookup_table<F: Field>(
// sparse
let low_degree_lut_len = 1 << sparse_degree;
let high_degree_lut_len = 1 << (log_n - sparse_degree - without_last_level as u32);
let mut twiddle_lut = vec![F::zero(); (low_degree_lut_len + high_degree_lut_len) as usize];
let mut twiddle_lut = vec![F::ZERO; (low_degree_lut_len + high_degree_lut_len) as usize];
parallelize(
&mut twiddle_lut[..low_degree_lut_len],
|twiddle_lut, start| {
Expand Down Expand Up @@ -378,7 +378,7 @@ pub fn parallel_fft<Scalar: Field, G: FftGroup<Scalar>>(a: &mut [G], omega: Scal
let twiddle_lut = generate_twiddle_lookup_table(omega, log_n, SPARSE_TWIDDLE_DEGREE, true);

// split fft
let mut tmp = vec![G::Scalar::ZERO; n];
let mut tmp = vec![Scalar::ZERO; n];
// if unsafe code is allowed, a 10% performance improvement can be achieved
// let mut tmp: Vec<G> = Vec::with_capacity(n);
// unsafe{ tmp.set_len(n); }
Expand Down
4 changes: 2 additions & 2 deletions halo2_proofs/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl Region {
}

/// The value of a particular cell within the circuit.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, Eq)]
pub enum CellValue<F: Field> {
/// An unassigned cell.
Unassigned,
Expand All @@ -110,7 +110,7 @@ pub enum CellValue<F: Field> {
Poison(usize),
}

impl<F: Group + Field> PartialEq for CellValue<F> {
impl<F: Field> PartialEq for CellValue<F> {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::Unassigned, Self::Unassigned) => true,
Expand Down
2 changes: 1 addition & 1 deletion halo2_proofs/src/dev/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub(super) fn load<'a, F: Field, T: ColumnType, Q: Into<AnyQuery> + Copy>(
}
*/

pub(super) fn load_slice<'a, F: FieldExt, T: ColumnType, Q: Into<AnyQuery> + Copy>(
pub(super) fn load_slice<'a, F: Field, T: ColumnType, Q: Into<AnyQuery> + Copy>(
n: i32,
row: i32,
queries: &'a [(Column<T>, Rotation)],
Expand Down
5 changes: 2 additions & 3 deletions halo2_proofs/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::plonk::{Any, Column};
use crate::poly::Polynomial;
use ff::Field;
use ff::PrimeField;
use halo2curves::FieldExt;
use halo2curves::{pairing::Engine, serde::SerdeObject, CurveAffine};
use num_bigint::BigUint;
use std::io;
Expand Down Expand Up @@ -42,13 +41,13 @@ pub(crate) trait CurveRead: CurveAffine {
}
impl<C: CurveAffine> CurveRead for C {}

pub fn field_to_bn<F: FieldExt>(f: &F) -> BigUint {
pub fn field_to_bn<F: Field>(f: &F) -> BigUint {
BigUint::from_bytes_le(f.to_repr().as_ref())

Check failure on line 45 in halo2_proofs/src/helpers.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

no method named `to_repr` found for reference `&F` in the current scope

error[E0599]: no method named `to_repr` found for reference `&F` in the current scope --> halo2_proofs/src/helpers.rs:45:30 | 45 | BigUint::from_bytes_le(f.to_repr().as_ref()) | ^^^^^^^ method not found in `&F` | = help: items from traits can only be used if the type parameter is bounded by the trait help: the following trait defines an item `to_repr`, perhaps you need to restrict type parameter `F` with it: | 44 | pub fn field_to_bn<F: Field + ff::PrimeField>(f: &F) -> BigUint { | ++++++++++++++++

Check failure on line 45 in halo2_proofs/src/helpers.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

no method named `to_repr` found for reference `&F` in the current scope

error[E0599]: no method named `to_repr` found for reference `&F` in the current scope --> halo2_proofs/src/helpers.rs:45:30 | 45 | BigUint::from_bytes_le(f.to_repr().as_ref()) | ^^^^^^^ method not found in `&F` | = help: items from traits can only be used if the type parameter is bounded by the trait help: the following trait defines an item `to_repr`, perhaps you need to restrict type parameter `F` with it: | 44 | pub fn field_to_bn<F: Field + ff::PrimeField>(f: &F) -> BigUint { | ++++++++++++++++
}

/// Input a big integer `bn`, compute a field element `f`
/// such that `f == bn % F::MODULUS`.
pub fn bn_to_field<F: FieldExt>(bn: &BigUint) -> F {
pub fn bn_to_field<F: Field>(bn: &BigUint) -> F {
let mut buf = bn.to_bytes_le();
buf.resize(64, 0u8);

Expand Down
2 changes: 1 addition & 1 deletion halo2_proofs/src/plonk/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ where
//*cell = C::Scalar::one();
//}
let idx = advice_values.len() - 1;
advice_values[idx] = Scheme::Scalar::one();
advice_values[idx] = Scheme::Scalar::ONE;
}

// Compute commitments to advice column polynomials
Expand Down
4 changes: 2 additions & 2 deletions halo2_proofs/src/plonk/vanishing/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ impl<C: CurveAffine> Argument<C> {
transcript: &mut T,
) -> Result<Committed<C>, Error> {
// Sample a random polynomial of degree n - 1
let random_poly = domain.constant_lagrange(C::Scalar::one());
let random_poly = domain.constant_lagrange(C::Scalar::ONE);
let random_poly = domain.lagrange_to_coeff(random_poly);
// Sample a random blinding factor
let random_blind = Blind(C::Scalar::zero());
let random_blind = Blind(C::Scalar::ZERO);
let c = params.commit(&random_poly, random_blind).to_affine();
// We write the identity point to the transcript which
// is the commitment of the zero polynomial.
Expand Down
4 changes: 2 additions & 2 deletions halo2_proofs/src/poly/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ impl<F: WithSmallOrderMulGroup<3>> EvaluationDomain<F> {
parallelize(a, |a, index| {
let mut c_power = c.pow_vartime(&[index as u64, 0, 0, 0]);
for a in a {
a = a * (&c_power);
*a = *a * (&c_power);
c_power = c_power * c;
}
});
Expand Down Expand Up @@ -654,7 +654,7 @@ fn test_l_i() {
points.push(domain.omega.pow(&[i, 0, 0, 0]));
}
for i in 0..8 {
let mut l_i = vec![Scalar::zero(); 8];
let mut l_i = vec![Scalar::ZERO; 8];
l_i[i] = Scalar::ONE;
let l_i = lagrange_interpolate(&points[..], &l_i[..]);
l.push(l_i);
Expand Down
8 changes: 4 additions & 4 deletions halo2_proofs/src/poly/multiopen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use super::{commitment::ParamsVerifier, PairMSM};
use crate::{
arithmetic::{eval_polynomial, CurveAffine, FieldExt},
arithmetic::{eval_polynomial, CurveAffine},
pairing::arithmetic::{MillerLoopResult, MultiMillerLoop},
poly::{msm::MSM, Coeff, Error, Polynomial},
};
Expand Down Expand Up @@ -129,7 +129,7 @@ impl<'r, 'params: 'r, C: CurveAffine> PartialEq for CommitmentReference<'r, C> {
}
}

trait Query<F: FieldExt>: Sized + Clone {
trait Query<F: Field>: Sized + Clone {
type Commitment: PartialEq + Clone;

fn get_rotation(&self) -> Rotation;
Expand All @@ -141,7 +141,7 @@ trait Query<F: FieldExt>: Sized + Clone {
#[cfg(test)]
mod tests {

use crate::arithmetic::{eval_polynomial, FieldExt};
use crate::arithmetic::{eval_polynomial};
use crate::pairing::bn256::{Bn256, Fr, G1Affine};
use crate::poly::{
commitment::{Params, ParamsVerifier},
Expand Down Expand Up @@ -173,7 +173,7 @@ mod tests {
use rand_core::OsRng;

use super::*;
use crate::arithmetic::{eval_polynomial, FieldExt};
use crate::arithmetic::{eval_polynomial};
use crate::poly::{commitment::Params, EvaluationDomain};
use crate::transcript::Challenge255;

Expand Down
2 changes: 1 addition & 1 deletion halo2_proofs/src/transcript/blake2b.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use super::{
use blake2b_simd::{Params as Blake2bParams, State as Blake2bState};
use ff::Field;
use group::ff::PrimeField;
use halo2curves::{Coordinates, CurveAffine, FieldExt};
use halo2curves::{Coordinates, CurveAffine};
use num_bigint::BigUint;
use std::convert::TryInto;
use std::io::{self, Read, Write};
Expand Down
Loading

0 comments on commit 7675aaf

Please sign in to comment.