Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
switched to appliedzkp/halo2
Browse files Browse the repository at this point in the history
  • Loading branch information
miha-stopar committed Dec 21, 2021
1 parent f559add commit 85166bb
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 96 deletions.
33 changes: 33 additions & 0 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ members = [
"keccak256",
"geth-utils",
"integration-tests",
"circuit-benchmarks"
"circuit-benchmarks",
"mpt"
]

Expand Down
1 change: 1 addition & 0 deletions keccak256/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ halo2 = { git = "https://github.com/appliedzkp/halo2.git", rev = "b78c39cacc1c79
itertools = "0.10.1"
num-bigint = "0.4.2"
num-traits = "0.2.14"
pasta_curves = "0.1"
pairing = { git = 'https://github.com/appliedzkp/pairing', package = "pairing_bn256" }
plotters = { version = "0.3.0", optional = true }

Expand Down
3 changes: 2 additions & 1 deletion mpt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ version = "0.1.0"
edition = "2018"

[dependencies]
halo2 = "0.0"
halo2 = { git = "https://github.com/appliedzkp/halo2.git", rev = "b78c39cacc1c79d287032f1b5f94beb661b3fb42" }
itertools = "0.10.1"
num-bigint = "0.4.2"
num-traits = "0.2.14"
pasta_curves = "0.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
keccak256 = { path = "../keccak256"}
pairing = { git = 'https://github.com/appliedzkp/pairing', package = "pairing_bn256" }
10 changes: 5 additions & 5 deletions mpt/src/account_leaf_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use halo2::{
plonk::{Advice, Column, ConstraintSystem, Expression, VirtualCells},
poly::Rotation,
};
use pasta_curves::arithmetic::FieldExt;
use pairing::{arithmetic::FieldExt, bn256::Fr as Fp};
use std::marker::PhantomData;

use crate::param::{HASH_WIDTH, R_TABLE_LEN};
Expand Down Expand Up @@ -92,8 +92,8 @@ impl<F: FieldExt> AccountLeafKeyChip<F> {
// 131 - 18 presents the key length.
// key length is at s_advices[0], key is from s_advices[1] to s_advices[1+key_len] (at most c_rlp1)

let c32 = Expression::Constant(F::from_u64(32));
let c128 = Expression::Constant(F::from_u64(128));
let c32 = Expression::Constant(F::from(32));
let c128 = Expression::Constant(F::from(128));
let key_len =
meta.query_advice(s_advices[0], Rotation::cur()) - c128;

Expand Down Expand Up @@ -178,8 +178,8 @@ impl<F: FieldExt> AccountLeafKeyChip<F> {
let sel1 = meta.query_advice(sel1, Rotation(rot));
let sel2 = meta.query_advice(sel2, Rotation(rot));

let c32 = Expression::Constant(F::from_u64(32));
let c48 = Expression::Constant(F::from_u64(48));
let c32 = Expression::Constant(F::from(32));
let c48 = Expression::Constant(F::from(48));

// If sel1 = 1, we have nibble+48 in s_advices[0].
let s_advice1 = meta.query_advice(s_advices[1], Rotation::cur());
Expand Down
8 changes: 4 additions & 4 deletions mpt/src/account_leaf_nonce_balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use halo2::{
plonk::{Advice, Column, ConstraintSystem, Expression, VirtualCells},
poly::Rotation,
};
use pasta_curves::arithmetic::FieldExt;
use pairing::{arithmetic::FieldExt, bn256::Fr as Fp};
use std::marker::PhantomData;

use crate::param::{HASH_WIDTH, R_TABLE_LEN};
Expand Down Expand Up @@ -56,8 +56,8 @@ impl<F: FieldExt> AccountLeafNonceBalanceChip<F> {
// TODO: nonce and balance compared to the input

let one = Expression::Constant(F::one());
let c128 = Expression::Constant(F::from_u64(128));
let c248 = Expression::Constant(F::from_u64(248));
let c128 = Expression::Constant(F::from(128));
let c248 = Expression::Constant(F::from(248));
let acc_prev = meta.query_advice(acc, Rotation::prev());
let acc_mult_prev = meta.query_advice(acc_mult_s, Rotation::prev());
let acc_mult_tmp = meta.query_advice(acc_mult_c, Rotation::cur());
Expand Down Expand Up @@ -142,7 +142,7 @@ impl<F: FieldExt> AccountLeafNonceBalanceChip<F> {
z_expr = z_expr * z_counter.clone();
}

let c32 = Expression::Constant(F::from_u64(32));
let c32 = Expression::Constant(F::from(32));
let mut counter = c32.clone() - nonce_len.clone() + one.clone();
let mut is_trailing_zero_or_last_key = one.clone();

Expand Down
4 changes: 2 additions & 2 deletions mpt/src/account_leaf_storage_codehash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use halo2::{
plonk::{Advice, Column, ConstraintSystem, Expression, VirtualCells},
poly::Rotation,
};
use pasta_curves::arithmetic::FieldExt;
use pairing::{arithmetic::FieldExt, bn256::Fr as Fp};
use std::marker::PhantomData;

use crate::param::HASH_WIDTH;
Expand Down Expand Up @@ -43,7 +43,7 @@ impl<F: FieldExt> AccountLeafStorageCodehashChip<F> {
// We have codehash length in c_rlp2 (which is 160 presenting 128 + 32).
// We have codehash in c_advices.

let c160 = Expression::Constant(F::from_u64(160));
let c160 = Expression::Constant(F::from(160));
let mut rot = -1;
if !is_s {
rot = -2;
Expand Down
6 changes: 3 additions & 3 deletions mpt/src/branch_acc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use halo2::{
},
poly::Rotation,
};
use pasta_curves::arithmetic::FieldExt;
use pairing::{arithmetic::FieldExt, bn256::Fr as Fp};
use std::{marker::PhantomData, u64};

use crate::param::{HASH_WIDTH, R_TABLE_LEN};
Expand Down Expand Up @@ -44,8 +44,8 @@ impl<F: FieldExt> BranchAccChip<F> {
let branch_mult_cur =
meta.query_advice(branch_mult, Rotation::cur());

let c128 = Expression::Constant(F::from_u64(128 as u64));
let c160 = Expression::Constant(F::from_u64(160 as u64));
let c128 = Expression::Constant(F::from(128 as u64));
let c160 = Expression::Constant(F::from(160 as u64));

// empty:
// branch_acc_curr = branch_acc_prev + 128 * branch_mult_prev
Expand Down
8 changes: 4 additions & 4 deletions mpt/src/leaf_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use halo2::{
plonk::{Advice, Column, ConstraintSystem, Expression, VirtualCells},
poly::Rotation,
};
use pasta_curves::arithmetic::FieldExt;
use pairing::{arithmetic::FieldExt, bn256::Fr as Fp};
use std::marker::PhantomData;

use crate::param::{HASH_WIDTH, R_TABLE_LEN};
Expand Down Expand Up @@ -42,7 +42,7 @@ impl<F: FieldExt> LeafKeyChip<F> {
let q_enable = q_enable(meta);
let mut constraints = vec![];

let c248 = Expression::Constant(F::from_u64(248));
let c248 = Expression::Constant(F::from(248));
let s_rlp1 = meta.query_advice(s_rlp1, Rotation::cur());
let is_long = meta.query_advice(s_keccak0, Rotation::cur());
let is_short = meta.query_advice(s_keccak1, Rotation::cur());
Expand Down Expand Up @@ -115,8 +115,8 @@ impl<F: FieldExt> LeafKeyChip<F> {
let sel1 = meta.query_advice(sel1, Rotation(rot));
let sel2 = meta.query_advice(sel2, Rotation(rot));

let c32 = Expression::Constant(F::from_u64(32));
let c48 = Expression::Constant(F::from_u64(48));
let c32 = Expression::Constant(F::from(32));
let c48 = Expression::Constant(F::from(48));

// For short RLP (key starts at s_advices[0]):

Expand Down
4 changes: 2 additions & 2 deletions mpt/src/leaf_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use halo2::{
},
poly::Rotation,
};
use pasta_curves::arithmetic::FieldExt;
use pairing::{arithmetic::FieldExt, bn256::Fr as Fp};
use std::marker::PhantomData;

use crate::param::{HASH_WIDTH, KECCAK_INPUT_WIDTH, KECCAK_OUTPUT_WIDTH};
Expand Down Expand Up @@ -34,7 +34,7 @@ impl<F: FieldExt> LeafValueChip<F> {
) -> LeafValueConfig {
let config = LeafValueConfig {};

meta.lookup(|meta| {
meta.lookup_any(|meta| {
let q_enable = q_enable(meta);

let mut rlc = meta.query_advice(acc, Rotation::prev());
Expand Down
Loading

0 comments on commit 85166bb

Please sign in to comment.