Skip to content

Commit

Permalink
chore: upgrade halo2curves, halo2proofs, halo2wrong to `v2023_0…
Browse files Browse the repository at this point in the history
…4_20` (#206)
  • Loading branch information
alexander-camuto authored Apr 26, 2023
1 parent d197bdb commit ea8e762
Show file tree
Hide file tree
Showing 23 changed files with 271 additions and 276 deletions.
95 changes: 27 additions & 68 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ crate-type = ["cdylib", "rlib"]


[dependencies]
halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2", tag = "v2023_02_02"}
halo2curves = { git = 'https://github.com/privacy-scaling-explorations/halo2curves', tag = "0.3.1" }
halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2", tag = "v2023_04_20"}
halo2curves = { git = 'https://github.com/privacy-scaling-explorations/halo2curves', tag = "0.3.2" }
rand = "0.8"
itertools = "0.10.3"
tensorflow = {version = "0.18.0", features = ["eager"], optional = true }
Expand All @@ -29,8 +29,8 @@ tabled = { version = "0.9.0", optional = true}
thiserror = "1.0.38"
hex = "0.4.3"
ethereum_types = { package = "ethereum-types", version = "0.14.1", default-features = false, features = ["std"]}
halo2_wrong_ecc = { git = "https://github.com/privacy-scaling-explorations/halo2wrong", package = "ecc", tag = "v2023_02_02"}
snark-verifier = { git = "https://github.com/privacy-scaling-explorations/snark-verifier", tag = "v2023_02_02"}
halo2_wrong_ecc = { git = "https://github.com/privacy-scaling-explorations/halo2wrong", package = "ecc", tag = "v2023_04_20"}
snark-verifier = { git = "https://github.com/privacy-scaling-explorations/snark-verifier", tag = "v2023_04_20"}
regex = "1"
colored = { version = "2.0.0", optional = true}
env_logger = { version = "0.10.0", optional = true}
Expand Down
8 changes: 4 additions & 4 deletions examples/conv2d_mnist/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use ezkl_lib::fieldutils::i32_to_felt;
use ezkl_lib::tensor::*;
use halo2_proofs::dev::MockProver;
use halo2_proofs::{
arithmetic::FieldExt,
circuit::{Layouter, SimpleFloorPlanner, Value},
plonk::{
create_proof, keygen_pk, keygen_vk, verify_proof, Circuit, Column, ConstraintSystem, Error,
Expand All @@ -25,6 +24,7 @@ use halo2_proofs::{
Blake2bRead, Blake2bWrite, Challenge255, TranscriptReadBuffer, TranscriptWriterBuffer,
},
};
use halo2curves::ff::PrimeField;
use halo2curves::pasta::vesta;
use halo2curves::pasta::Fp as F;
use mnist::*;
Expand All @@ -37,7 +37,7 @@ const K: usize = 20;

#[derive(Clone)]
struct Config<
F: FieldExt + TensorType,
F: PrimeField + TensorType + PartialOrd,
const LEN: usize, //LEN = CHOUT x OH x OW flattened //not supported yet in rust stable
const CLASSES: usize,
const BITS: usize,
Expand All @@ -61,7 +61,7 @@ struct Config<

#[derive(Clone)]
struct MyCircuit<
F: FieldExt + TensorType,
F: PrimeField + TensorType + PartialOrd,
const LEN: usize, //LEN = CHOUT x OH x OW flattened
const CLASSES: usize,
const BITS: usize,
Expand All @@ -85,7 +85,7 @@ struct MyCircuit<
}

impl<
F: FieldExt + TensorType,
F: PrimeField + TensorType + PartialOrd,
const LEN: usize,
const CLASSES: usize,
const BITS: usize,
Expand Down
8 changes: 4 additions & 4 deletions examples/mlp_4d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ use ezkl_lib::fieldutils::i32_to_felt;
use ezkl_lib::tensor::*;
use halo2_proofs::dev::MockProver;
use halo2_proofs::{
arithmetic::FieldExt,
circuit::{Layouter, SimpleFloorPlanner, Value},
plonk::{Circuit, Column, ConstraintSystem, Error, Instance},
};
use halo2curves::ff::PrimeField;
use halo2curves::pasta::Fp as F;
use std::marker::PhantomData;

const K: usize = 15;
// A columnar ReLu MLP
#[derive(Clone)]
struct MyConfig<F: FieldExt + TensorType> {
struct MyConfig<F: PrimeField + TensorType + PartialOrd> {
layer_config: PolyConfig<F>,
public_output: Column<Instance>,
}

#[derive(Clone)]
struct MyCircuit<
F: FieldExt + TensorType,
F: PrimeField + TensorType + PartialOrd,
const LEN: usize, //LEN = CHOUT x OH x OW flattened
const BITS: usize,
> {
Expand All @@ -34,7 +34,7 @@ struct MyCircuit<
_marker: PhantomData<F>,
}

impl<F: FieldExt + TensorType, const LEN: usize, const BITS: usize> Circuit<F>
impl<F: PrimeField + TensorType + PartialOrd, const LEN: usize, const BITS: usize> Circuit<F>
for MyCircuit<F, LEN, BITS>
{
type Config = MyConfig<F>;
Expand Down
14 changes: 8 additions & 6 deletions src/circuit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ mod tests;
use thiserror::Error;

use halo2_proofs::{
arithmetic::Field,
circuit::{Layouter, Region},
plonk::{ConstraintSystem, Constraints, Expression, Selector},
poly::Rotation,
};
use halo2curves::FieldExt;
use log::warn;
use serde::{Deserialize, Serialize};

Expand All @@ -32,6 +30,7 @@ use crate::{
use std::{collections::BTreeMap, error::Error, marker::PhantomData};

use self::{ops::lookup::LookupOp, table::Table};
use halo2curves::ff::{Field, PrimeField};

/// circuit related errors.
#[derive(Debug, Error)]
Expand Down Expand Up @@ -73,7 +72,7 @@ impl From<String> for CheckMode {

/// Configuration for an accumulated arg.
#[derive(Clone, Debug, Default)]
pub struct BaseConfig<F: FieldExt + TensorType> {
pub struct BaseConfig<F: PrimeField + TensorType + PartialOrd> {
/// the inputs to the accumulated operations.
pub inputs: Vec<VarTensor>,
/// the VarTensor reserved for lookup operations (could be an element of inputs)
Expand All @@ -95,7 +94,7 @@ pub struct BaseConfig<F: FieldExt + TensorType> {
_marker: PhantomData<F>,
}

impl<F: FieldExt + TensorType> BaseConfig<F> {
impl<F: PrimeField + TensorType + PartialOrd> BaseConfig<F> {
/// Returns a new [BaseConfig] with no inputs, no selectors, and no tables.
pub fn dummy(col_size: usize) -> Self {
Self {
Expand Down Expand Up @@ -225,7 +224,10 @@ impl<F: FieldExt + TensorType> BaseConfig<F> {
output: &VarTensor,
bits: usize,
nl: &LookupOp,
) -> Result<(), Box<dyn Error>> {
) -> Result<(), Box<dyn Error>>
where
F: Field,
{
let mut selectors = BTreeMap::new();
let table =
if let std::collections::btree_map::Entry::Vacant(e) = self.tables.entry(nl.clone()) {
Expand All @@ -240,7 +242,7 @@ impl<F: FieldExt + TensorType> BaseConfig<F> {
selectors.insert((nl.clone(), x), qlookup);
let _ = cs.lookup(Op::<F>::as_str(nl), |cs| {
let qlookup = cs.query_selector(qlookup);
let not_qlookup = Expression::Constant(<F as Field>::one()) - qlookup.clone();
let not_qlookup = Expression::Constant(<F as Field>::ONE) - qlookup.clone();
let (default_x, default_y): (F, F) = nl.default_pair();
vec![
(
Expand Down
Loading

0 comments on commit ea8e762

Please sign in to comment.