Skip to content

Commit

Permalink
patch aggr for stitching
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-camuto committed Nov 30, 2023
1 parent 52cf017 commit 4e17b85
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

5 changes: 2 additions & 3 deletions src/circuit/modules/kzg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use halo2_proofs::poly::commitment::{Blind, Params};
use halo2_proofs::poly::kzg::commitment::ParamsKZG;
use halo2_proofs::{circuit::*, plonk::*};
use halo2curves::bn256::{Bn256, G1Affine};
use halo2curves::ff::Field;
use halo2curves::group::prime::PrimeCurveAffine;
use halo2curves::group::Curve;
use halo2curves::CurveAffine;
Expand Down Expand Up @@ -57,7 +56,7 @@ impl KZGChip {

(0..num_unusable_rows).for_each(|i| {
for p in &mut poly {
p[(n + i as u64) as usize] = Fp::ZERO;
p[(n + i as u64) as usize] = Blind::default().0;
}
});

Expand All @@ -69,7 +68,7 @@ impl KZGChip {

let mut advice_commitments_projective = vec![];
for a in poly {
advice_commitments_projective.push(params.commit_lagrange(&a, Blind(Fp::ZERO)))
advice_commitments_projective.push(params.commit_lagrange(&a, Blind::default()))
}

let mut advice_commitments =
Expand Down
17 changes: 16 additions & 1 deletion src/graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,21 @@ impl GraphSettings {
pub fn uses_modules(&self) -> bool {
!self.module_sizes.max_constraints() > 0
}

/// if any visibility is encrypted or hashed
pub fn module_requires_fixed(&self) -> bool {
if self.run_args.input_visibility.is_encrypted()
|| self.run_args.input_visibility.is_hashed()
|| self.run_args.output_visibility.is_encrypted()
|| self.run_args.output_visibility.is_hashed()
|| self.run_args.param_visibility.is_encrypted()
|| self.run_args.param_visibility.is_hashed()
{
true
} else {
false
}
}
}

/// Configuration for a computational graph / model loaded from a `.onnx` file.
Expand Down Expand Up @@ -1245,7 +1260,7 @@ impl Circuit<Fp> for GraphCircuit {
params.total_assignments,
params.run_args.num_inner_cols,
params.total_const_size,
params.uses_modules(),
params.module_requires_fixed(),
);

module_configs.configure_complex_modules(cs, visibility, params.module_sizes.clone());
Expand Down
5 changes: 3 additions & 2 deletions src/graph/vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ impl<F: PrimeField + TensorType + PartialOrd> ModelVars<F> {
var_len: usize,
num_inner_cols: usize,
num_constants: usize,
uses_modules: bool,
module_requires_fixed: bool,
) -> Self {
info!("number of blinding factors: {}", cs.blinding_factors());

Expand All @@ -431,7 +431,8 @@ impl<F: PrimeField + TensorType + PartialOrd> ModelVars<F> {
num_inner_cols
);

let num_const_cols = VarTensor::constant_cols(cs, logrows, num_constants, uses_modules);
let num_const_cols =
VarTensor::constant_cols(cs, logrows, num_constants, module_requires_fixed);
debug!("model uses {} fixed columns", num_const_cols);

ModelVars {
Expand Down
6 changes: 3 additions & 3 deletions src/tensor/var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ impl VarTensor {
cs: &mut ConstraintSystem<F>,
logrows: usize,
num_constants: usize,
uses_modules: bool,
module_requires_fixed: bool,
) -> usize {
if num_constants == 0 && !uses_modules {
if num_constants == 0 && !module_requires_fixed {
return 0;
} else if num_constants == 0 && uses_modules {
} else if num_constants == 0 && module_requires_fixed {
let col = cs.fixed_column();
cs.enable_constant(col);
return 1;
Expand Down

0 comments on commit 4e17b85

Please sign in to comment.