Skip to content

Commit

Permalink
update: Bump to latest Halo2 tag (privacy-scaling-explorations#499)
Browse files Browse the repository at this point in the history
  • Loading branch information
CPerezz authored May 6, 2022
1 parent 818f48e commit 5152005
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 50 deletions.
43 changes: 21 additions & 22 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 circuit-benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"

[dependencies]
ff = "0.11"
halo2_proofs = { git = "https://github.com/appliedzkp/halo2.git", tag = "v2022_05_03" }
halo2_proofs = { git = "https://github.com/appliedzkp/halo2.git", tag = "v2022_05_06" }
ark-std = { version = "0.3", features = ["print-trace"] }
zkevm-circuits = { path = "../zkevm-circuits" }
keccak256 = { path = "../keccak256" }
Expand Down
2 changes: 1 addition & 1 deletion eth-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ethers-core = "0.6"
ethers-providers = "0.6"
hex = "0.4"
lazy_static = "1.4"
halo2_proofs = { git = "https://github.com/appliedzkp/halo2.git", tag = "v2022_05_03" }
halo2_proofs = { git = "https://github.com/appliedzkp/halo2.git", tag = "v2022_05_06" }
regex = "1.5.4"
serde = {version = "1.0.130", features = ["derive"] }
serde_json = "1.0.66"
Expand Down
18 changes: 13 additions & 5 deletions eth-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ pub mod geth_types;

pub use bytecode::Bytecode;
pub use error::Error;
use halo2_proofs::pairing;
use pairing::group::ff::PrimeField;
use halo2_proofs::{
arithmetic::{Field as Halo2Field, FieldExt},
pairing::{
bn256::{Fq, Fr},
group::ff::PrimeField,
},
};

use crate::evm_types::{memory::Memory, stack::Stack, storage::Storage};
use crate::evm_types::{Gas, GasCost, OpcodeId, ProgramCounter};
Expand All @@ -33,21 +38,24 @@ pub use ethers_core::types::{
transaction::{eip2930::AccessList, response::Transaction},
Address, Block, Bytes, H160, H256, U256, U64,
};
use pairing::arithmetic::FieldExt;
use pairing::bn256::Fr;

use serde::{de, Deserialize};
use std::collections::HashMap;
use std::fmt;
use std::str::FromStr;

/// Trait used to reduce verbosity with the declaration of the [`FieldExt`]
/// trait and its repr.
pub trait Field: FieldExt + PrimeField<Repr = [u8; 32]> {}
pub trait Field: FieldExt + Halo2Field + PrimeField<Repr = [u8; 32]> {}

// Impl custom `Field` trait for BN256 Fr to be used and consistent with the
// rest of the workspace.
impl Field for Fr {}

// Impl custom `Field` trait for BN256 Frq to be used and consistent with the
// rest of the workspace.
impl Field for Fq {}

/// Trait used to define types that can be converted to a 256 bit scalar value.
pub trait ToScalar<F> {
/// Convert the type to a scalar value.
Expand Down
3 changes: 1 addition & 2 deletions gadgets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ edition = "2021"
authors = ["The appliedzkp team"]

[dependencies]
ff = "0.11"
halo2_proofs = { git = "https://github.com/appliedzkp/halo2.git", tag = "v2022_05_03" }
halo2_proofs = { git = "https://github.com/appliedzkp/halo2.git", tag = "v2022_05_06" }
sha3 = "0.7.2"
eth-types = { path = "../eth-types" }
digest = "0.7.6"
Expand Down
6 changes: 3 additions & 3 deletions gadgets/src/evm_word.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ impl<F: Field> WordConfig<F> {
#[cfg(test)]
mod tests {
use super::*;
use ff::PrimeField;
use halo2_proofs::arithmetic::Field as HaloField;
use halo2_proofs::pairing::bn256::Fr as Fp;
use halo2_proofs::{
arithmetic::Field as Halo2Field,
circuit::SimpleFloorPlanner,
dev::{FailureLocation, MockProver, VerifyFailure},
pairing::bn256::Fr as Fp,
pairing::group::ff::PrimeField,
plonk::{Circuit, Instance},
};
use rand::SeedableRng;
Expand Down
6 changes: 3 additions & 3 deletions gadgets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ pub mod evm_word;
pub mod is_zero;
pub mod monotone;

use eth_types::Field;
use halo2_proofs::circuit::AssignedCell;
use halo2_proofs::pairing::arithmetic::FieldExt;

#[allow(dead_code)]
/// An assigned cell in the circuit.
#[derive(Clone, Debug)]
pub struct Variable<T, F: FieldExt> {
pub struct Variable<T, F: Field> {
assig_cell: AssignedCell<F, F>,
value: Option<T>,
}

impl<T, F: FieldExt> Variable<T, F> {
impl<T, F: Field> Variable<T, F> {
pub(crate) fn new(assig_cell: AssignedCell<F, F>, value: Option<T>) -> Self {
Self { assig_cell, value }
}
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ url = "2.2.2"
pretty_assertions = "1.0.0"
log = "0.4.14"
env_logger = "0.9"
halo2_proofs = { git = "https://github.com/appliedzkp/halo2.git", tag = "v2022_05_03" }
halo2_proofs = { git = "https://github.com/appliedzkp/halo2.git", tag = "v2022_05_06" }
ff = "0.11"

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion keccak256/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"
dev-graph = ["halo2_proofs/dev-graph", "plotters"]

[dependencies]
halo2_proofs = { git = "https://github.com/appliedzkp/halo2.git", tag = "v2022_05_03" }
halo2_proofs = { git = "https://github.com/appliedzkp/halo2.git", tag = "v2022_05_06" }
itertools = "0.10.1"
num-bigint = "0.4.2"
num-traits = "0.2.14"
Expand Down
6 changes: 2 additions & 4 deletions keccak256/src/permutation/pi.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use eth_types::Field;
use halo2_proofs::circuit::AssignedCell;
use halo2_proofs::pairing::arithmetic::FieldExt;
use itertools::Itertools;
use std::convert::TryInto;

Expand All @@ -8,9 +8,7 @@ use std::convert::TryInto;
/// It has no gates. We just have to permute the previous state into the correct
/// order. The copy constrain in the next gate can then enforce the Pi step
/// permutation.
pub fn pi_gate_permutation<F: FieldExt>(
state: [AssignedCell<F, F>; 25],
) -> [AssignedCell<F, F>; 25] {
pub fn pi_gate_permutation<F: Field>(state: [AssignedCell<F, F>; 25]) -> [AssignedCell<F, F>; 25] {
let state: [AssignedCell<F, F>; 25] = (0..5)
.cartesian_product(0..5)
.map(|(x, y)| state[5 * ((x + 3 * y) % 5) + x].clone())
Expand Down
1 change: 1 addition & 0 deletions keccak256/src/permutation/theta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ mod tests {
use crate::common::*;
use crate::gate_helpers::biguint_to_f;
use crate::keccak_arith::*;
use eth_types::Field;
use halo2_proofs::pairing::bn256::Fr as Fp;
use halo2_proofs::{
circuit::{Layouter, SimpleFloorPlanner},
Expand Down
2 changes: 1 addition & 1 deletion prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ethers-providers = "0.6"
eth-types = { path = "../eth-types" }
hyper = { version = "0.14.16", features = ["server"] }
rand_xorshift = "0.3"
halo2_proofs = { git = "https://github.com/appliedzkp/halo2.git", tag = "v2022_05_03" }
halo2_proofs = { git = "https://github.com/appliedzkp/halo2.git", tag = "v2022_05_06" }
log = "0.4.14"
rand = "0.8.4"
serde = { version = "1.0.136", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion zkevm-circuits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2018"

[dependencies]
ff = "0.11"
halo2_proofs = { git = "https://github.com/appliedzkp/halo2.git", tag = "v2022_05_03" }
halo2_proofs = { git = "https://github.com/appliedzkp/halo2.git", tag = "v2022_05_06" }
bigint = "4"
num = "0.4"
sha3 = "0.7.2"
Expand Down
9 changes: 4 additions & 5 deletions zkevm-circuits/src/state_circuit/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use gadgets::{
};
use halo2_proofs::{
circuit::{Layouter, Region, SimpleFloorPlanner},
pairing::arithmetic::FieldExt,
plonk::{Advice, Circuit, Column, ConstraintSystem, Error, Expression, Fixed, VirtualCells},
poly::Rotation,
};
Expand Down Expand Up @@ -53,7 +52,7 @@ const MAX_DEGREE: usize = 15;

/// A mapping derived from witnessed operations.
#[derive(Clone, Debug)]
pub(crate) struct BusMapping<F: FieldExt> {
pub(crate) struct BusMapping<F: Field> {
rw_counter: Variable<F, F>,
target: Variable<F, F>,
is_write: Variable<F, F>,
Expand All @@ -64,7 +63,7 @@ pub(crate) struct BusMapping<F: FieldExt> {

#[derive(Clone, Debug)]
pub struct Config<
F: FieldExt,
F: Field,
// When SANITY_CHECK is true, max_address/rw_counter/stack_address are
// required to be in the range of
// MEMORY_ADDRESS_MAX/RW_COUNTER_MAX/STACK_ADDRESS_MAX during circuit
Expand Down Expand Up @@ -593,7 +592,7 @@ impl<
/// State Circuit struct.
#[derive(Default)]
pub struct StateCircuit<
F: FieldExt,
F: Field,
const SANITY_CHECK: bool,
const RW_COUNTER_MAX: usize,
const MEMORY_ADDRESS_MAX: usize,
Expand All @@ -607,7 +606,7 @@ pub struct StateCircuit<
}

impl<
F: FieldExt,
F: Field,
const SANITY_CHECK: bool,
const RW_COUNTER_MAX: usize,
const MEMORY_ADDRESS_MAX: usize,
Expand Down

0 comments on commit 5152005

Please sign in to comment.