mirror of https://github.com/zcash/halo2.git
Temporarily disable thread-safe-region fetature, fix clippy warnings
This commit is contained in:
parent
da9d34e78b
commit
4c155be610
|
@ -55,7 +55,6 @@ getrandom = { version = "0.2", features = ["js"] }
|
|||
default = ["batch", "bits"]
|
||||
bits = ["halo2curves/bits"]
|
||||
gadget-traces = ["backtrace"]
|
||||
thread-safe-region = []
|
||||
sanity-checks = []
|
||||
batch = ["rand_core/getrandom"]
|
||||
circuit-params = []
|
||||
|
|
|
@ -390,7 +390,7 @@ impl<C: CurveAffine> Evaluator<C> {
|
|||
let blinding_factors = pk.vk.cs.blinding_factors();
|
||||
let last_rotation = Rotation(-((blinding_factors + 1) as i32));
|
||||
let chunk_len = pk.vk.cs.degree() - 2;
|
||||
let delta_start = beta * &C::Scalar::ZETA;
|
||||
let delta_start = beta * C::Scalar::ZETA;
|
||||
|
||||
let first_set = sets.first().unwrap();
|
||||
let last_set = sets.last().unwrap();
|
||||
|
@ -863,7 +863,7 @@ pub fn evaluate<F: Field, B: Basis>(
|
|||
},
|
||||
&|challenge| challenges[challenge.index()],
|
||||
&|a| -a,
|
||||
&|a, b| a + &b,
|
||||
&|a, b| a + b,
|
||||
&|a, b| a * b,
|
||||
&|a, scalar| a * scalar,
|
||||
);
|
||||
|
|
|
@ -199,7 +199,7 @@ impl<C: CurveAffine> Permuted<C> {
|
|||
.zip(self.permuted_input_expression[start..].iter())
|
||||
.zip(self.permuted_table_expression[start..].iter())
|
||||
{
|
||||
*lookup_product = (*beta + permuted_input_value) * &(*gamma + permuted_table_value);
|
||||
*lookup_product = (*beta + permuted_input_value) * (*gamma + permuted_table_value);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -214,8 +214,8 @@ impl<C: CurveAffine> Permuted<C> {
|
|||
for (i, product) in product.iter_mut().enumerate() {
|
||||
let i = i + start;
|
||||
|
||||
*product *= &(self.compressed_input_expression[i] + &*beta);
|
||||
*product *= &(self.compressed_table_expression[i] + &*gamma);
|
||||
*product *= &(self.compressed_input_expression[i] + *beta);
|
||||
*product *= &(self.compressed_table_expression[i] + *gamma);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -276,7 +276,7 @@ impl<C: CurveAffine> Permuted<C> {
|
|||
|
||||
input_term += &(*beta);
|
||||
table_term += &(*gamma);
|
||||
right *= &(input_term * &table_term);
|
||||
right *= &(input_term * table_term);
|
||||
|
||||
assert_eq!(left, right);
|
||||
}
|
||||
|
|
|
@ -109,8 +109,8 @@ impl<C: CurveAffine> Evaluated<C> {
|
|||
// z(\omega X) (a'(X) + \beta) (s'(X) + \gamma)
|
||||
// - z(X) (\theta^{m-1} a_0(X) + ... + a_{m-1}(X) + \beta) (\theta^{m-1} s_0(X) + ... + s_{m-1}(X) + \gamma)
|
||||
let left = self.product_next_eval
|
||||
* &(self.permuted_input_eval + &*beta)
|
||||
* &(self.permuted_table_eval + &*gamma);
|
||||
* (self.permuted_input_eval + *beta)
|
||||
* (self.permuted_table_eval + *gamma);
|
||||
|
||||
let compress_expressions = |expressions: &[Expression<C::Scalar>]| {
|
||||
expressions
|
||||
|
@ -124,28 +124,28 @@ impl<C: CurveAffine> Evaluated<C> {
|
|||
&|query| instance_evals[query.index.unwrap()],
|
||||
&|challenge| challenges[challenge.index()],
|
||||
&|a| -a,
|
||||
&|a, b| a + &b,
|
||||
&|a, b| a * &b,
|
||||
&|a, scalar| a * &scalar,
|
||||
&|a, b| a + b,
|
||||
&|a, b| a * b,
|
||||
&|a, scalar| a * scalar,
|
||||
)
|
||||
})
|
||||
.fold(C::Scalar::ZERO, |acc, eval| acc * &*theta + &eval)
|
||||
.fold(C::Scalar::ZERO, |acc, eval| acc * *theta + eval)
|
||||
};
|
||||
let right = self.product_eval
|
||||
* &(compress_expressions(&argument.input_expressions) + &*beta)
|
||||
* &(compress_expressions(&argument.table_expressions) + &*gamma);
|
||||
* (compress_expressions(&argument.input_expressions) + *beta)
|
||||
* (compress_expressions(&argument.table_expressions) + *gamma);
|
||||
|
||||
(left - &right) * &active_rows
|
||||
(left - right) * active_rows
|
||||
};
|
||||
|
||||
std::iter::empty()
|
||||
.chain(
|
||||
// l_0(X) * (1 - z(X)) = 0
|
||||
Some(l_0 * &(C::Scalar::ONE - &self.product_eval)),
|
||||
Some(l_0 * (C::Scalar::ONE - self.product_eval)),
|
||||
)
|
||||
.chain(
|
||||
// l_last(X) * (z(X)^2 - z(X)) = 0
|
||||
Some(l_last * &(self.product_eval.square() - &self.product_eval)),
|
||||
Some(l_last * (self.product_eval.square() - self.product_eval)),
|
||||
)
|
||||
.chain(
|
||||
// (1 - (l_last(X) + l_blind(X))) * (
|
||||
|
@ -156,13 +156,13 @@ impl<C: CurveAffine> Evaluated<C> {
|
|||
)
|
||||
.chain(Some(
|
||||
// l_0(X) * (a'(X) - s'(X)) = 0
|
||||
l_0 * &(self.permuted_input_eval - &self.permuted_table_eval),
|
||||
l_0 * (self.permuted_input_eval - self.permuted_table_eval),
|
||||
))
|
||||
.chain(Some(
|
||||
// (1 - (l_last(X) + l_blind(X))) * (a′(X) − s′(X))⋅(a′(X) − a′(\omega^{-1} X)) = 0
|
||||
(self.permuted_input_eval - &self.permuted_table_eval)
|
||||
* &(self.permuted_input_eval - &self.permuted_input_inv_eval)
|
||||
* &active_rows,
|
||||
(self.permuted_input_eval - self.permuted_table_eval)
|
||||
* (self.permuted_input_eval - self.permuted_input_inv_eval)
|
||||
* active_rows,
|
||||
))
|
||||
}
|
||||
|
||||
|
|
|
@ -13,13 +13,18 @@ use crate::{
|
|||
use halo2_middleware::circuit::{Any, ColumnMid};
|
||||
use halo2_middleware::permutation::{ArgumentV2, AssemblyMid};
|
||||
|
||||
#[cfg(feature = "thread-safe-region")]
|
||||
// NOTE: Temporarily disabled thread-safe-region feature. Regions are a frontend concept, so the
|
||||
// thread-safe support for them should be only in the frontend package.
|
||||
|
||||
// #[cfg(feature = "thread-safe-region")]
|
||||
use crate::multicore::{IndexedParallelIterator, IntoParallelIterator, ParallelIterator};
|
||||
|
||||
/*
|
||||
#[cfg(feature = "thread-safe-region")]
|
||||
use std::collections::{BTreeSet, HashMap};
|
||||
*/
|
||||
|
||||
#[cfg(not(feature = "thread-safe-region"))]
|
||||
// #[cfg(not(feature = "thread-safe-region"))]
|
||||
/// Struct that accumulates all the necessary data in order to construct the permutation argument.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Assembly {
|
||||
|
@ -33,7 +38,7 @@ pub struct Assembly {
|
|||
sizes: Vec<Vec<usize>>,
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "thread-safe-region"))]
|
||||
// #[cfg(not(feature = "thread-safe-region"))]
|
||||
impl Assembly {
|
||||
pub(crate) fn new_from_assembly_mid(
|
||||
n: usize,
|
||||
|
@ -143,12 +148,13 @@ impl Assembly {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
#[cfg(feature = "thread-safe-region")]
|
||||
/// Struct that accumulates all the necessary data in order to construct the permutation argument.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Assembly {
|
||||
/// Columns that participate on the copy permutation argument.
|
||||
columns: Vec<ColumnMid<Any>>,
|
||||
columns: Vec<ColumnMid>,
|
||||
/// Mapping of the actual copies done.
|
||||
cycles: Vec<Vec<(usize, usize)>>,
|
||||
/// Mapping of the actual copies done.
|
||||
|
@ -165,10 +171,10 @@ pub struct Assembly {
|
|||
impl Assembly {
|
||||
pub(crate) fn new_from_assembly_mid(
|
||||
n: usize,
|
||||
p: &Argument,
|
||||
p: &ArgumentV2,
|
||||
a: &AssemblyMid,
|
||||
) -> Result<Self, Error> {
|
||||
let mut assembly = Self::new(n, p);
|
||||
let mut assembly = Self::new(n, &p.clone().into());
|
||||
for copy in &a.copies {
|
||||
assembly.copy(copy.0.column, copy.0.row, copy.1.column, copy.1.row)?;
|
||||
}
|
||||
|
@ -176,21 +182,27 @@ impl Assembly {
|
|||
}
|
||||
|
||||
pub(crate) fn new(n: usize, p: &Argument) -> Self {
|
||||
// Initialize the copy vector to keep track of copy constraints in all
|
||||
// the permutation arguments.
|
||||
let mut columns = vec![];
|
||||
for i in 0..p.columns.len() {
|
||||
// Computes [(i, 0), (i, 1), ..., (i, n - 1)]
|
||||
columns.push((0..n).map(|j| (i, j)).collect());
|
||||
}
|
||||
|
||||
Assembly {
|
||||
columns: p.columns.clone(),
|
||||
cycles: Vec::with_capacity(n),
|
||||
ordered_cycles: Vec::with_capacity(n),
|
||||
aux: HashMap::new(),
|
||||
col_len: n,
|
||||
num_cols: p.columns.len(),
|
||||
columns: p.columns.clone().into_iter().map(|c| c.into()).collect(),
|
||||
mapping: columns.clone(),
|
||||
aux: columns,
|
||||
sizes: vec![vec![1usize; n]; p.columns.len()],
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn copy(
|
||||
&mut self,
|
||||
left_column: ColumnMid<Any>,
|
||||
left_column: ColumnMid,
|
||||
left_row: usize,
|
||||
right_column: ColumnMid<Any>,
|
||||
right_column: ColumnMid,
|
||||
right_row: usize,
|
||||
) -> Result<(), Error> {
|
||||
let left_column = self
|
||||
|
@ -316,7 +328,7 @@ impl Assembly {
|
|||
}
|
||||
|
||||
/// Returns columns that participate in the permutation argument.
|
||||
pub fn columns(&self) -> &[ColumnMid<Any>] {
|
||||
pub fn columns(&self) -> &[ColumnMid] {
|
||||
&self.columns
|
||||
}
|
||||
|
||||
|
@ -331,6 +343,7 @@ impl Assembly {
|
|||
})
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
pub(crate) fn build_pk<'params, C: CurveAffine, P: Params<'params, C>>(
|
||||
params: &P,
|
||||
|
|
|
@ -110,7 +110,7 @@ pub(in crate::plonk) fn permutation_commit<
|
|||
.zip(values[column.index()][start..].iter())
|
||||
.zip(permuted_column_values[start..].iter())
|
||||
{
|
||||
*modified_values *= &(*beta * permuted_value + &*gamma + value);
|
||||
*modified_values *= *beta * permuted_value + *gamma + value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -128,13 +128,13 @@ pub(in crate::plonk) fn permutation_commit<
|
|||
Any::Instance => instance,
|
||||
};
|
||||
parallelize(&mut modified_values, |modified_values, start| {
|
||||
let mut deltaomega = deltaomega * &omega.pow_vartime([start as u64, 0, 0, 0]);
|
||||
let mut deltaomega = deltaomega * omega.pow_vartime([start as u64, 0, 0, 0]);
|
||||
for (modified_values, value) in modified_values
|
||||
.iter_mut()
|
||||
.zip(values[column.index()][start..].iter())
|
||||
{
|
||||
// Multiply by p_j(\omega^i) + \delta^j \omega^i \beta
|
||||
*modified_values *= &(deltaomega * &*beta + &*gamma + value);
|
||||
*modified_values *= deltaomega * *beta + *gamma + value;
|
||||
deltaomega *= ω
|
||||
}
|
||||
});
|
||||
|
|
|
@ -123,13 +123,13 @@ impl<C: CurveAffine> Evaluated<C> {
|
|||
.chain(
|
||||
self.sets
|
||||
.first()
|
||||
.map(|first_set| l_0 * &(C::Scalar::ONE - &first_set.permutation_product_eval)),
|
||||
.map(|first_set| l_0 * (C::Scalar::ONE - first_set.permutation_product_eval)),
|
||||
)
|
||||
// Enforce only for the last set.
|
||||
// l_last(X) * (z_l(X)^2 - z_l(X)) = 0
|
||||
.chain(self.sets.last().map(|last_set| {
|
||||
(last_set.permutation_product_eval.square() - &last_set.permutation_product_eval)
|
||||
* &l_last
|
||||
(last_set.permutation_product_eval.square() - last_set.permutation_product_eval)
|
||||
* l_last
|
||||
}))
|
||||
// Except for the first set, enforce.
|
||||
// l_0(X) * (z_i(X) - z_{i-1}(\omega^(last) X)) = 0
|
||||
|
@ -144,7 +144,7 @@ impl<C: CurveAffine> Evaluated<C> {
|
|||
last_set.permutation_product_last_eval.unwrap(),
|
||||
)
|
||||
})
|
||||
.map(move |(set, prev_last)| (set - &prev_last) * &l_0),
|
||||
.map(move |(set, prev_last)| (set - prev_last) * l_0),
|
||||
)
|
||||
// And for all the sets we enforce:
|
||||
// (1 - (l_last(X) + l_blind(X))) * (
|
||||
|
@ -175,12 +175,12 @@ impl<C: CurveAffine> Evaluated<C> {
|
|||
})
|
||||
.zip(permutation_evals.iter())
|
||||
{
|
||||
left *= &(eval + &(*beta * permutation_eval) + &*gamma);
|
||||
left *= eval + (*beta * permutation_eval) + *gamma;
|
||||
}
|
||||
|
||||
let mut right = set.permutation_product_eval;
|
||||
let mut current_delta = (*beta * &*x)
|
||||
* &(<C::Scalar as PrimeField>::DELTA
|
||||
let mut current_delta = (*beta * *x)
|
||||
* (<C::Scalar as PrimeField>::DELTA
|
||||
.pow_vartime([(chunk_index * chunk_len) as u64]));
|
||||
for eval in columns.iter().map(|&column| match column.column_type() {
|
||||
Any::Advice(_) => {
|
||||
|
@ -193,11 +193,11 @@ impl<C: CurveAffine> Evaluated<C> {
|
|||
instance_evals[vk.cs.get_any_query_index(column, Rotation::cur())]
|
||||
}
|
||||
}) {
|
||||
right *= &(eval + ¤t_delta + &*gamma);
|
||||
right *= eval + current_delta + *gamma;
|
||||
current_delta *= &C::Scalar::DELTA;
|
||||
}
|
||||
|
||||
(left - &right) * (C::Scalar::ONE - &(l_last + &l_blind))
|
||||
(left - right) * (C::Scalar::ONE - (l_last + l_blind))
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -258,6 +258,7 @@ impl<
|
|||
}
|
||||
|
||||
/// Commit the `witness` at `phase` and return the challenges after `phase`.
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub fn commit_phase(
|
||||
&mut self,
|
||||
phase: u8,
|
||||
|
@ -454,7 +455,7 @@ impl<
|
|||
.iter()
|
||||
.map(|lookup| {
|
||||
lookup_commit_permuted(
|
||||
&lookup,
|
||||
lookup,
|
||||
pk,
|
||||
params,
|
||||
domain,
|
||||
|
@ -527,7 +528,7 @@ impl<
|
|||
.iter()
|
||||
.map(|shuffle| {
|
||||
shuffle_commit_product(
|
||||
&shuffle,
|
||||
shuffle,
|
||||
pk,
|
||||
params,
|
||||
domain,
|
||||
|
|
|
@ -81,31 +81,31 @@ impl<C: CurveAffine> Evaluated<C> {
|
|||
&|query| instance_evals[query.index.unwrap()],
|
||||
&|challenge| challenges[challenge.index()],
|
||||
&|a| -a,
|
||||
&|a, b| a + &b,
|
||||
&|a, b| a * &b,
|
||||
&|a, scalar| a * &scalar,
|
||||
&|a, b| a + b,
|
||||
&|a, b| a * b,
|
||||
&|a, scalar| a * scalar,
|
||||
)
|
||||
})
|
||||
.fold(C::Scalar::ZERO, |acc, eval| acc * &*theta + &eval)
|
||||
.fold(C::Scalar::ZERO, |acc, eval| acc * *theta + eval)
|
||||
};
|
||||
// z(\omega X) (s(X) + \gamma)
|
||||
let left = self.product_next_eval
|
||||
* &(compress_expressions(&argument.shuffle_expressions) + &*gamma);
|
||||
* (compress_expressions(&argument.shuffle_expressions) + *gamma);
|
||||
// z(X) (a(X) + \gamma)
|
||||
let right =
|
||||
self.product_eval * &(compress_expressions(&argument.input_expressions) + &*gamma);
|
||||
self.product_eval * (compress_expressions(&argument.input_expressions) + *gamma);
|
||||
|
||||
(left - &right) * &active_rows
|
||||
(left - right) * active_rows
|
||||
};
|
||||
|
||||
std::iter::empty()
|
||||
.chain(
|
||||
// l_0(X) * (1 - z'(X)) = 0
|
||||
Some(l_0 * &(C::Scalar::ONE - &self.product_eval)),
|
||||
Some(l_0 * (C::Scalar::ONE - self.product_eval)),
|
||||
)
|
||||
.chain(
|
||||
// l_last(X) * (z(X)^2 - z(X)) = 0
|
||||
Some(l_last * &(self.product_eval.square() - &self.product_eval)),
|
||||
Some(l_last * (self.product_eval.square() - self.product_eval)),
|
||||
)
|
||||
.chain(
|
||||
// (1 - (l_last(X) + l_blind(X))) * ( z(\omega X) (s(X) + \gamma) - z(X) (a(X) + \gamma))
|
||||
|
|
|
@ -95,7 +95,7 @@ impl<C: CurveAffine> PartiallyEvaluated<C> {
|
|||
y: ChallengeY<C>,
|
||||
xn: C::Scalar,
|
||||
) -> Evaluated<C, P::MSM> {
|
||||
let expected_h_eval = expressions.fold(C::Scalar::ZERO, |h_eval, v| h_eval * &*y + &v);
|
||||
let expected_h_eval = expressions.fold(C::Scalar::ZERO, |h_eval, v| h_eval * *y + v);
|
||||
let expected_h_eval = expected_h_eval * ((xn - C::Scalar::ONE).invert().unwrap());
|
||||
|
||||
let h_commitment =
|
||||
|
|
|
@ -327,9 +327,9 @@ where
|
|||
&|query| instance_evals[query.index.unwrap()],
|
||||
&|challenge| challenges[challenge.index()],
|
||||
&|a| -a,
|
||||
&|a, b| a + &b,
|
||||
&|a, b| a * &b,
|
||||
&|a, scalar| a * &scalar,
|
||||
&|a, b| a + b,
|
||||
&|a, b| a * b,
|
||||
&|a, scalar| a * scalar,
|
||||
)
|
||||
})
|
||||
}))
|
||||
|
|
|
@ -29,11 +29,11 @@ pub struct Column<C: ColumnType> {
|
|||
pub column_type: C,
|
||||
}
|
||||
|
||||
impl Into<metadata::Column> for Column<Any> {
|
||||
fn into(self) -> metadata::Column {
|
||||
impl From<Column<Any>> for metadata::Column {
|
||||
fn from(val: Column<Any>) -> Self {
|
||||
metadata::Column {
|
||||
index: self.index(),
|
||||
column_type: *self.column_type(),
|
||||
index: val.index(),
|
||||
column_type: *val.column_type(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -126,11 +126,11 @@ impl From<ColumnMid> for Column<Any> {
|
|||
}
|
||||
}
|
||||
|
||||
impl Into<ColumnMid> for Column<Any> {
|
||||
fn into(self) -> ColumnMid {
|
||||
impl From<Column<Any>> for ColumnMid {
|
||||
fn from(val: Column<Any>) -> Self {
|
||||
ColumnMid {
|
||||
index: self.index(),
|
||||
column_type: *self.column_type(),
|
||||
index: val.index(),
|
||||
column_type: *val.column_type(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -469,11 +469,11 @@ impl Challenge {
|
|||
}
|
||||
}
|
||||
|
||||
impl Into<ChallengeMid> for Challenge {
|
||||
fn into(self) -> ChallengeMid {
|
||||
impl From<Challenge> for ChallengeMid {
|
||||
fn from(val: Challenge) -> Self {
|
||||
ChallengeMid {
|
||||
index: self.index,
|
||||
phase: self.phase,
|
||||
index: val.index,
|
||||
phase: val.phase,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -699,9 +699,9 @@ pub enum Expression<F> {
|
|||
Scaled(Box<Expression<F>>, F),
|
||||
}
|
||||
|
||||
impl<F> Into<ExpressionMid<F>> for Expression<F> {
|
||||
fn into(self) -> ExpressionMid<F> {
|
||||
match self {
|
||||
impl<F> From<Expression<F>> for ExpressionMid<F> {
|
||||
fn from(val: Expression<F>) -> Self {
|
||||
match val {
|
||||
Expression::Constant(c) => ExpressionMid::Constant(c),
|
||||
Expression::Selector(_) => unreachable!(),
|
||||
Expression::Fixed(FixedQuery {
|
||||
|
@ -1538,7 +1538,7 @@ impl QueriesMap {
|
|||
rotation: query.rotation,
|
||||
})
|
||||
}
|
||||
ExpressionMid::Challenge(c) => Expression::Challenge(c.clone().into()),
|
||||
ExpressionMid::Challenge(c) => Expression::Challenge((*c).into()),
|
||||
ExpressionMid::Negated(e) => Expression::Negated(Box::new(self.as_expression(e))),
|
||||
ExpressionMid::Sum(lhs, rhs) => Expression::Sum(
|
||||
Box::new(self.as_expression(lhs)),
|
||||
|
@ -1566,13 +1566,13 @@ impl<F: Field> From<ConstraintSystem<F>> for ConstraintSystemV2Backend<F> {
|
|||
gates: cs
|
||||
.gates
|
||||
.into_iter()
|
||||
.map(|mut g| {
|
||||
.flat_map(|mut g| {
|
||||
let constraint_names = std::mem::take(&mut g.constraint_names);
|
||||
let gate_name = g.name.clone();
|
||||
g.polys.into_iter().enumerate().map(move |(i, e)| {
|
||||
let name = match constraint_names[i].as_str() {
|
||||
"" => gate_name.clone(),
|
||||
constraint_name => format!("{}:{}", gate_name, constraint_name),
|
||||
constraint_name => format!("{gate_name}:{constraint_name}"),
|
||||
};
|
||||
GateV2Backend {
|
||||
name,
|
||||
|
@ -1580,7 +1580,6 @@ impl<F: Field> From<ConstraintSystem<F>> for ConstraintSystemV2Backend<F> {
|
|||
}
|
||||
})
|
||||
})
|
||||
.flatten()
|
||||
.collect(),
|
||||
permutation: halo2_middleware::permutation::ArgumentV2 {
|
||||
columns: cs
|
||||
|
@ -1759,6 +1758,7 @@ fn cs2_collect_queries_shuffles<F: Field>(
|
|||
/// Collect all queries used in the expressions of gates, lookups and shuffles. Map the
|
||||
/// expressions of gates, lookups and shuffles into equivalent ones with indexed query
|
||||
/// references.
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub fn collect_queries<F: Field>(
|
||||
cs2: &ConstraintSystemV2Backend<F>,
|
||||
) -> (
|
||||
|
@ -1972,7 +1972,7 @@ impl<F: Field> Default for ConstraintSystem<F> {
|
|||
advice_queries: Vec::new(),
|
||||
num_advice_queries: Vec::new(),
|
||||
instance_queries: Vec::new(),
|
||||
permutation: permutation::Argument::new(),
|
||||
permutation: permutation::Argument::default(),
|
||||
lookups: Vec::new(),
|
||||
shuffles: Vec::new(),
|
||||
general_column_annotations: HashMap::new(),
|
||||
|
|
|
@ -5,7 +5,7 @@ use halo2_middleware::circuit::Any;
|
|||
use halo2_middleware::permutation::{ArgumentV2, Cell};
|
||||
|
||||
/// A permutation argument.
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Default, Debug, Clone)]
|
||||
pub struct Argument {
|
||||
/// A sequence of columns involved in the argument.
|
||||
pub columns: Vec<Column<Any>>,
|
||||
|
@ -20,10 +20,6 @@ impl From<ArgumentV2> for Argument {
|
|||
}
|
||||
|
||||
impl Argument {
|
||||
pub fn new() -> Self {
|
||||
Argument { columns: vec![] }
|
||||
}
|
||||
|
||||
/// Returns the minimum circuit degree required by the permutation argument.
|
||||
/// The argument may use larger degree gates depending on the actual
|
||||
/// circuit's degree and how many columns are involved in the permutation.
|
||||
|
|
|
@ -103,17 +103,23 @@ where
|
|||
projectives_msms: Vec<MSMKZG<E>>,
|
||||
}
|
||||
|
||||
impl<E: Engine + Debug> Default for PreMSM<E>
|
||||
where
|
||||
E::G1Affine: CurveAffine<ScalarExt = <E as Engine>::Fr, CurveExt = <E as Engine>::G1>,
|
||||
E::G1: CurveExt<AffineExt = E::G1Affine>,
|
||||
{
|
||||
fn default() -> Self {
|
||||
PreMSM {
|
||||
projectives_msms: vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Engine + Debug> PreMSM<E>
|
||||
where
|
||||
E::G1Affine: CurveAffine<ScalarExt = <E as Engine>::Fr, CurveExt = <E as Engine>::G1>,
|
||||
E::G1: CurveExt<AffineExt = E::G1Affine>,
|
||||
{
|
||||
pub fn new() -> Self {
|
||||
PreMSM {
|
||||
projectives_msms: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn normalize(self) -> MSMKZG<E> {
|
||||
let (scalars, bases) = self
|
||||
.projectives_msms
|
||||
|
|
|
@ -72,7 +72,7 @@ where
|
|||
let h2 = transcript.read_point().map_err(|_| Error::SamplingError)?;
|
||||
|
||||
let (mut z_0_diff_inverse, mut z_0) = (E::Fr::ZERO, E::Fr::ZERO);
|
||||
let (mut outer_msm, mut r_outer_acc) = (PreMSM::<E>::new(), E::Fr::ZERO);
|
||||
let (mut outer_msm, mut r_outer_acc) = (PreMSM::<E>::default(), E::Fr::ZERO);
|
||||
for (i, (rotation_set, power_of_v)) in rotation_sets.iter().zip(powers(*v)).enumerate() {
|
||||
let diffs: Vec<E::Fr> = super_point_set
|
||||
.iter()
|
||||
|
|
|
@ -28,6 +28,7 @@ pub use halo2_common::circuit::{layouter, Layouter, Value};
|
|||
/// copy constraints assignments. The output of this function can then be used for the key
|
||||
/// generation, and proof generation.
|
||||
/// If `compress_selectors` is true, multiple selector columns may be multiplexed.
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub fn compile_circuit<F: Field, ConcreteCircuit: Circuit<F>>(
|
||||
k: u32,
|
||||
circuit: &ConcreteCircuit,
|
||||
|
|
|
@ -720,8 +720,8 @@ impl<F: FromUniformBytes<64> + Ord> MockProver<F> {
|
|||
v
|
||||
}));
|
||||
|
||||
#[cfg(feature = "thread-safe-region")]
|
||||
prover.permutation.build_ordered_mapping();
|
||||
// #[cfg(feature = "thread-safe-region")]
|
||||
// prover.permutation.build_ordered_mapping();
|
||||
|
||||
Ok(prover)
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use std::collections::HashSet;
|
||||
use std::{iter, num::ParseIntError, str::FromStr};
|
||||
|
||||
use crate::plonk::Circuit;
|
||||
use halo2_common::plonk::circuit::Circuit;
|
||||
use halo2_middleware::ff::{Field, FromUniformBytes};
|
||||
use serde::Deserialize;
|
||||
use serde_derive::Serialize;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use halo2_common::plonk::{
|
||||
circuit::{Circuit, Column},
|
||||
Assignment, Challenge, ConstraintSystem, Error, FloorPlanner, Selector,
|
||||
};
|
||||
use halo2_middleware::circuit::{Advice, Any, Fixed, Instance};
|
||||
use halo2_middleware::ff::Field;
|
||||
use halo2_middleware::plonk::Assigned;
|
||||
use tabbycat::{AttrList, Edge, GraphBuilder, GraphType, Identity, StmtList};
|
||||
|
||||
use crate::{
|
||||
circuit::Value,
|
||||
plonk::{
|
||||
Advice, Any, Assigned, Assignment, Challenge, Circuit, Column, ConstraintSystem, Error,
|
||||
Fixed, FloorPlanner, Instance, Selector,
|
||||
},
|
||||
};
|
||||
use crate::circuit::Value;
|
||||
|
||||
pub mod layout;
|
||||
|
||||
|
@ -154,7 +154,7 @@ impl<F: Field> Assignment<F> for Graph {
|
|||
_: usize,
|
||||
_: Column<Any>,
|
||||
_: usize,
|
||||
) -> Result<(), crate::plonk::Error> {
|
||||
) -> Result<(), halo2_common::plonk::Error> {
|
||||
// Do nothing; we don't care about permutations in this context.
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -6,11 +6,9 @@ use plotters::{
|
|||
use std::collections::HashSet;
|
||||
use std::ops::Range;
|
||||
|
||||
use crate::{
|
||||
circuit::layouter::RegionColumn,
|
||||
dev::cost::Layout,
|
||||
plonk::{Any, Circuit, Column, ConstraintSystem, FloorPlanner},
|
||||
};
|
||||
use crate::{circuit::layouter::RegionColumn, dev::cost::Layout};
|
||||
use halo2_common::plonk::{circuit::Column, Circuit, ConstraintSystem, FloorPlanner};
|
||||
use halo2_middleware::circuit::Any;
|
||||
|
||||
/// Graphical renderer for circuit layouts.
|
||||
///
|
||||
|
|
|
@ -68,6 +68,7 @@ gumdrop = "0.8"
|
|||
proptest = "1"
|
||||
dhat = "0.3.2"
|
||||
serde_json = "1"
|
||||
plotters = { version = "0.3.0", features = ["bitmap_backend", "bitmap_encoder", "ttf"] }
|
||||
|
||||
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies]
|
||||
getrandom = { version = "0.2", features = ["js"] }
|
||||
|
|
|
@ -30,6 +30,12 @@ pub mod arithmetic {
|
|||
/// Tools for developing circuits.
|
||||
pub mod dev {
|
||||
pub use halo2_frontend::dev::{metadata, FailureLocation, MockProver, VerifyFailure};
|
||||
|
||||
#[cfg(feature = "cost-estimator")]
|
||||
pub use halo2_frontend::dev::cost_model;
|
||||
|
||||
#[cfg(feature = "dev-graph")]
|
||||
pub use halo2_frontend::dev::{circuit_dot_graph, CircuitLayout};
|
||||
}
|
||||
/// Contains utilities for performing arithmetic over univariate polynomials in
|
||||
/// various forms, including computing commitments to them and provably opening
|
||||
|
|
|
@ -65,6 +65,7 @@ struct MyCircuitConfig {
|
|||
}
|
||||
|
||||
impl MyCircuitConfig {
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn assign_gate<F: Field + From<u64>>(
|
||||
&self,
|
||||
region: &mut Region<'_, F>,
|
||||
|
@ -516,7 +517,7 @@ fn test_mycircuit_full_legacy() {
|
|||
create_proof::<KZGCommitmentScheme<Bn256>, ProverSHPLONK<'_, Bn256>, _, _, _, _>(
|
||||
¶ms,
|
||||
&pk,
|
||||
&[circuit.clone()],
|
||||
&[circuit],
|
||||
&[instances_slice],
|
||||
&mut rng,
|
||||
&mut transcript,
|
||||
|
@ -584,7 +585,7 @@ fn test_mycircuit_full_split() {
|
|||
.unwrap();
|
||||
let mut challenges = HashMap::new();
|
||||
for phase in 0..cs.phases().count() {
|
||||
println!("phase {}", phase);
|
||||
println!("phase {phase}");
|
||||
let witness = witness_calc.calc(phase as u8, &challenges).unwrap();
|
||||
challenges = prover.commit_phase(phase as u8, witness).unwrap();
|
||||
}
|
||||
|
|
|
@ -190,17 +190,11 @@ pub struct ColumnMid {
|
|||
}
|
||||
|
||||
/// An advice column
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash)]
|
||||
#[derive(Default, Clone, Copy, Eq, PartialEq, Hash)]
|
||||
pub struct Advice {
|
||||
pub phase: u8,
|
||||
}
|
||||
|
||||
impl Default for Advice {
|
||||
fn default() -> Advice {
|
||||
Advice { phase: 0 }
|
||||
}
|
||||
}
|
||||
|
||||
impl Advice {
|
||||
/// Returns `Advice` in given `Phase`
|
||||
pub fn new(phase: u8) -> Advice {
|
||||
|
|
Loading…
Reference in New Issue