forked from privacy-scaling-explorations/zkevm-circuits
-
Notifications
You must be signed in to change notification settings - Fork 391
/
Copy pathconfig.rs
64 lines (55 loc) · 1.77 KB
/
config.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use halo2_proofs::plonk::{Column, Instance};
use snark_verifier::loader::halo2::halo2_ecc::{
ecc::{BaseFieldEccChip, EccChip},
fields::fp::FpConfig,
halo2_base::gates::{flex_gate::FlexGateConfig, range::RangeConfig},
};
use aggregator::ConfigParams as RecursionCircuitConfigParams;
use super::*;
#[derive(Clone)]
pub struct RecursionConfig {
/// The non-native field arithmetic config from halo2-lib.
pub base_field_config: FpConfig<Fr, Fq>,
/// The single instance column to hold the public input to the [`RecursionCircuit`].
pub instance: Column<Instance>,
}
impl RecursionConfig {
pub fn configure(
meta: &mut ConstraintSystem<Fr>,
params: RecursionCircuitConfigParams,
) -> Self {
assert!(
params.limb_bits == BITS && params.num_limbs == LIMBS,
"For now we fix limb_bits = {}, otherwise change code",
BITS
);
let base_field_config = FpConfig::configure(
meta,
params.strategy,
¶ms.num_advice,
¶ms.num_lookup_advice,
params.num_fixed,
params.lookup_bits,
params.limb_bits,
params.num_limbs,
halo2_base::utils::modulus::<Fq>(),
0,
params.degree as usize,
);
let instance = meta.instance_column();
meta.enable_equality(instance);
Self {
base_field_config,
instance,
}
}
pub fn gate(&self) -> &FlexGateConfig<Fr> {
&self.base_field_config.range.gate
}
pub fn range(&self) -> &RangeConfig<Fr> {
&self.base_field_config.range
}
pub fn ecc_chip(&self) -> BaseFieldEccChip<G1Affine> {
EccChip::construct(self.base_field_config.clone())
}
}