@@ -9,7 +9,7 @@ use crate::{
9
9
ROMType ,
10
10
chip_handler:: utils:: rlc_chip_record,
11
11
error:: ZKVMError ,
12
- expression:: { Expression , Fixed , Instance , WitIn } ,
12
+ expression:: { Expression , Fixed , Instance , StructuralWitIn , WitIn } ,
13
13
structs:: { ProgramParams , ProvingKey , RAMType , VerifyingKey , WitnessId } ,
14
14
witness:: RowMajorMatrix ,
15
15
} ;
@@ -59,14 +59,6 @@ pub struct LogupTableExpression<E: ExtensionField> {
59
59
pub table_len : usize ,
60
60
}
61
61
62
- // TODO encapsulate few information of table spec to SetTableAddrType value
63
- // once confirm syntax is friendly and parsed by recursive verifier
64
- #[ derive( Clone , Debug ) ]
65
- pub enum SetTableAddrType {
66
- FixedAddr ,
67
- DynamicAddr ( DynamicAddr ) ,
68
- }
69
-
70
62
#[ derive( Clone , Debug ) ]
71
63
pub struct DynamicAddr {
72
64
pub addr_witin_id : usize ,
@@ -75,12 +67,13 @@ pub struct DynamicAddr {
75
67
76
68
#[ derive( Clone , Debug ) ]
77
69
pub struct SetTableSpec {
78
- pub addr_type : SetTableAddrType ,
79
- pub len : usize ,
70
+ pub len : Option < usize > ,
71
+ pub structural_witins : Vec < StructuralWitIn > ,
80
72
}
81
73
82
74
#[ derive( Clone , Debug ) ]
83
75
pub struct SetTableExpression < E : ExtensionField > {
76
+ /// table expression
84
77
pub expr : Expression < E > ,
85
78
86
79
// TODO make decision to have enum/struct
@@ -92,10 +85,12 @@ pub struct SetTableExpression<E: ExtensionField> {
92
85
pub struct ConstraintSystem < E : ExtensionField > {
93
86
pub ( crate ) ns : NameSpace ,
94
87
95
- // pub platform: Platform,
96
88
pub num_witin : WitnessId ,
97
89
pub witin_namespace_map : Vec < String > ,
98
90
91
+ pub num_structural_witin : WitnessId ,
92
+ pub structural_witin_namespace_map : Vec < String > ,
93
+
99
94
pub num_fixed : usize ,
100
95
pub fixed_namespace_map : Vec < String > ,
101
96
@@ -152,6 +147,8 @@ impl<E: ExtensionField> ConstraintSystem<E> {
152
147
num_witin : 0 ,
153
148
// platform,
154
149
witin_namespace_map : vec ! [ ] ,
150
+ num_structural_witin : 0 ,
151
+ structural_witin_namespace_map : vec ! [ ] ,
155
152
num_fixed : 0 ,
156
153
fixed_namespace_map : vec ! [ ] ,
157
154
ns : NameSpace :: new ( root_name_fn) ,
@@ -209,20 +206,36 @@ impl<E: ExtensionField> ConstraintSystem<E> {
209
206
}
210
207
211
208
pub fn create_witin < NR : Into < String > , N : FnOnce ( ) -> NR > ( & mut self , n : N ) -> WitIn {
212
- let wit_in = WitIn {
213
- id : {
214
- let id = self . num_witin ;
215
- self . num_witin = self . num_witin . strict_add ( 1 ) ;
216
- id
217
- } ,
218
- } ;
209
+ let wit_in = WitIn { id : self . num_witin } ;
210
+ self . num_witin = self . num_witin . strict_add ( 1 ) ;
219
211
220
212
let path = self . ns . compute_path ( n ( ) . into ( ) ) ;
221
213
self . witin_namespace_map . push ( path) ;
222
214
223
215
wit_in
224
216
}
225
217
218
+ pub fn create_structural_witin < NR : Into < String > , N : FnOnce ( ) -> NR > (
219
+ & mut self ,
220
+ n : N ,
221
+ max_len : usize ,
222
+ offset : u32 ,
223
+ multi_factor : usize ,
224
+ ) -> StructuralWitIn {
225
+ let wit_in = StructuralWitIn {
226
+ id : self . num_structural_witin ,
227
+ max_len,
228
+ offset,
229
+ multi_factor,
230
+ } ;
231
+ self . num_structural_witin = self . num_structural_witin . strict_add ( 1 ) ;
232
+
233
+ let path = self . ns . compute_path ( n ( ) . into ( ) ) ;
234
+ self . structural_witin_namespace_map . push ( path) ;
235
+
236
+ wit_in
237
+ }
238
+
226
239
pub fn create_fixed < NR : Into < String > , N : FnOnce ( ) -> NR > (
227
240
& mut self ,
228
241
n : N ,
0 commit comments