25
25
use ff:: PrimeFieldBits ;
26
26
use halo2_proofs:: {
27
27
circuit:: { AssignedCell , Region , Value } ,
28
- plonk:: {
29
- Advice , Column , ConstraintSystem , Constraints , Error , Expression , Selector , VirtualCells ,
30
- } ,
28
+ plonk:: { Advice , Column , ConstraintSystem , Error , Expression , Selector , VirtualCells } ,
31
29
poly:: Rotation ,
32
30
} ;
33
31
34
- use super :: range_check;
35
-
36
32
use std:: marker:: PhantomData ;
37
33
38
34
/// The running sum $[z_0, ..., z_W]$. If created in strict mode, $z_W = 0$.
@@ -86,10 +82,6 @@ impl<F: PrimeFieldBits, const WINDOW_NUM_BITS: usize> RunningSumConfig<F, WINDOW
86
82
87
83
/// `perm` MUST include the advice column `z`.
88
84
///
89
- /// # Panics
90
- ///
91
- /// Panics if WINDOW_NUM_BITS > 3.
92
- ///
93
85
/// # Side-effects
94
86
///
95
87
/// `z` will be equality-enabled.
@@ -98,25 +90,19 @@ impl<F: PrimeFieldBits, const WINDOW_NUM_BITS: usize> RunningSumConfig<F, WINDOW
98
90
q_range_check : Selector ,
99
91
z : Column < Advice > ,
100
92
) -> Self {
101
- assert ! ( WINDOW_NUM_BITS <= 3 ) ;
102
-
103
93
meta. enable_equality ( z) ;
104
94
105
- let config = Self {
95
+ // It is the caller's responsibility to enforce the range-check using q_range_check.
96
+ // The selector q_range_check will be enabled on every row of the decomposition,
97
+ // but is not tied to a gate or expression within this helper.
98
+ //
99
+ // This is to support different range check methods (e.g. expression, lookup).
100
+
101
+ Self {
106
102
q_range_check,
107
103
z,
108
104
_marker : PhantomData ,
109
- } ;
110
-
111
- // https://p.z.cash/halo2-0.1:decompose-short-range
112
- meta. create_gate ( "range check" , |meta| {
113
- let q_range_check = meta. query_selector ( config. q_range_check ) ;
114
- let word = config. window_expr ( meta) ;
115
-
116
- Constraints :: with_selector ( q_range_check, Some ( range_check ( word, 1 << WINDOW_NUM_BITS ) ) )
117
- } ) ;
118
-
119
- config
105
+ }
120
106
}
121
107
122
108
/// Expression for a window
0 commit comments