Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Commit 06a5172

Browse files
authored
Feat: update the configuration params for sig circuit as we increase max_num_sig to be greater than 100 (#722)
* update configuration params for sig circuit to support max_sigs = 100 * update params for max_num_sig equals 128
1 parent f2ce8f5 commit 06a5172

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

zkevm-circuits/src/sig_circuit.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,13 @@ impl<F: Field> SubCircuitConfig<F> for SigCircuitConfig<F> {
111111

112112
// halo2-ecc's ECDSA config
113113
//
114-
// - num_advice: 36
115-
// - num_lookup_advice: 17
114+
// get the following parameters by running
115+
// `cargo test --release --package zkevm-circuits --lib sig_circuit::test::sign_verify --
116+
// --nocapture`
117+
// - num_advice: 56
118+
// - num_lookup_advice: 8
116119
// - num_fixed: 1
117-
// - lookup_bits: 13
120+
// - lookup_bits: 19
118121
// - limb_bits: 88
119122
// - num_limbs: 3
120123
//
@@ -123,9 +126,9 @@ impl<F: Field> SubCircuitConfig<F> for SigCircuitConfig<F> {
123126
meta,
124127
FpStrategy::Simple,
125128
&num_advice,
126-
&[17],
129+
&[8],
127130
1,
128-
13,
131+
LOG_TOTAL_NUM_ROWS - 1,
129132
88,
130133
3,
131134
modulus::<Fp>(),
@@ -781,12 +784,12 @@ impl<F: Field> SigCircuit<F> {
781784

782785
// IMPORTANT: Move to Phase2 before RLC
783786
log::info!("before proceeding to the next phase");
784-
ctx.print_stats(&["Range"]);
785787

786788
#[cfg(not(feature = "onephase"))]
787789
{
788790
// finalize the current lookup table before moving to next phase
789791
ecdsa_chip.finalize(&mut ctx);
792+
ctx.print_stats(&["ECDSA context"]);
790793
ctx.next_phase();
791794
}
792795

@@ -843,7 +846,7 @@ impl<F: Field> SigCircuit<F> {
843846
let lookup_cells = ecdsa_chip.finalize(&mut ctx);
844847
log::info!("total number of lookup cells: {}", lookup_cells);
845848

846-
ctx.print_stats(&["Range"]);
849+
ctx.print_stats(&["ECDSA context"]);
847850
Ok(assigned_keccak_values_and_sigs
848851
.iter()
849852
.map(|a| a.1.clone())

zkevm-circuits/src/sig_circuit/test.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ use rand::{Rng, RngCore};
1818
#[test]
1919
fn sign_verify() {
2020
use super::utils::LOG_TOTAL_NUM_ROWS;
21+
use crate::sig_circuit::utils::MAX_NUM_SIG;
2122
use rand::SeedableRng;
2223
use rand_xorshift::XorShiftRng;
2324
use sha3::{Digest, Keccak256};
2425
let mut rng = XorShiftRng::seed_from_u64(1);
25-
let max_sigs = [16];
26+
let max_sigs = [1, 16, MAX_NUM_SIG];
2627
for max_sig in max_sigs.iter() {
2728
log::debug!("testing for {} signatures", max_sig);
2829
let mut signatures = Vec::new();

zkevm-circuits/src/sig_circuit/utils.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ use halo2_proofs::{
1212

1313
// Hard coded parameters.
1414
// FIXME: allow for a configurable param.
15-
pub(super) const MAX_NUM_SIG: usize = 32;
16-
// Each ecdsa signature requires 534042 cells
17-
// We set CELLS_PER_SIG = 535000 to allows for a few buffer
18-
pub(super) const CELLS_PER_SIG: usize = 535000;
15+
pub(super) const MAX_NUM_SIG: usize = 128;
16+
// Each ecdsa signature requires 456786 cells
17+
// We set CELLS_PER_SIG = 457000 to allows for a few buffer
18+
pub(super) const CELLS_PER_SIG: usize = 457000;
1919
// Total number of rows allocated for ecdsa chip
2020
pub(super) const LOG_TOTAL_NUM_ROWS: usize = 20;
2121
// Max number of columns allowed

0 commit comments

Comments
 (0)