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
32
use pasta_curves:: arithmetic:: FieldExt ;
36
33
use std:: marker:: PhantomData ;
37
34
@@ -45,7 +42,7 @@ pub struct RunningSum<F: FieldExt + PrimeFieldBits, const WINDOW_NUM_BITS: usize
45
42
46
43
impl < F : FieldExt + PrimeFieldBits , const WINDOW_NUM_BITS : usize > RunningSum < F , WINDOW_NUM_BITS > {
47
44
/// Returns windows derived from the intermediate values of the running sum.
48
- pub ( crate ) fn windows ( & self ) -> Vec < Option < F > > {
45
+ pub ( crate ) fn windows ( & self ) -> Vec < Value < F > > {
49
46
let mut windows = Vec :: new ( ) ;
50
47
// k_i = z_i - (2^K * z_{i+1})
51
48
for i in 0 ..( self . zs . len ( ) - 1 ) {
@@ -88,10 +85,6 @@ impl<F: FieldExt + PrimeFieldBits, const WINDOW_NUM_BITS: usize>
88
85
89
86
/// `perm` MUST include the advice column `z`.
90
87
///
91
- /// # Panics
92
- ///
93
- /// Panics if WINDOW_NUM_BITS > 3.
94
- ///
95
88
/// # Side-effects
96
89
///
97
90
/// `z` will be equality-enabled.
@@ -100,25 +93,19 @@ impl<F: FieldExt + PrimeFieldBits, const WINDOW_NUM_BITS: usize>
100
93
q_range_check : Selector ,
101
94
z : Column < Advice > ,
102
95
) -> Self {
103
- assert ! ( WINDOW_NUM_BITS <= 3 ) ;
104
-
105
96
meta. enable_equality ( z) ;
106
97
107
- let config = Self {
98
+ // It is the caller's responsibility to enforce the range-check using q_range_check.
99
+ // The selector q_range_check will be enabled on every row of the decomposition,
100
+ // but is not tied to a gate or expression within this helper.
101
+ //
102
+ // This is to support different range check methods (e.g. expression, lookup).
103
+
104
+ Self {
108
105
q_range_check,
109
106
z,
110
107
_marker : PhantomData ,
111
- } ;
112
-
113
- // https://p.z.cash/halo2-0.1:decompose-short-range
114
- meta. create_gate ( "range check" , |meta| {
115
- let q_range_check = meta. query_selector ( config. q_range_check ) ;
116
- let word = config. window_expr ( meta) ;
117
-
118
- Constraints :: with_selector ( q_range_check, Some ( range_check ( word, 1 << WINDOW_NUM_BITS ) ) )
119
- } ) ;
120
-
121
- config
108
+ }
122
109
}
123
110
124
111
/// Expression for a window
0 commit comments