@@ -8,7 +8,7 @@ use crate::{orion::utils::SubsetSumLUTs, PCS_SOUNDNESS_BITS};
8
8
9
9
use super :: {
10
10
linear_code:: { OrionCode , OrionCodeParameter } ,
11
- utils:: { transpose_in_place, OrionPCSError , OrionResult } ,
11
+ utils:: { transpose_in_place, OrionPCSError , OrionResult , TensorIOPPCS } ,
12
12
} ;
13
13
14
14
/**********************************************************
@@ -21,6 +21,16 @@ pub struct OrionPublicParams {
21
21
pub code_instance : OrionCode ,
22
22
}
23
23
24
+ impl TensorIOPPCS for OrionPublicParams {
25
+ fn codeword_len ( & self ) -> usize {
26
+ self . code_instance . code_len ( )
27
+ }
28
+
29
+ fn hamming_weight ( & self ) -> f64 {
30
+ self . code_instance . hamming_weight ( )
31
+ }
32
+ }
33
+
24
34
#[ derive( Clone , Debug ) ]
25
35
pub struct OrionCommitmentWithData < F , ComPackF >
26
36
where
@@ -53,17 +63,6 @@ pub struct OrionProof<EvalF: Field + FieldSerde> {
53
63
}
54
64
55
65
impl OrionPublicParams {
56
- pub ( crate ) fn row_col_from_variables < F : Field > ( num_variables : usize ) -> ( usize , usize ) {
57
- let poly_variables: usize = num_variables;
58
-
59
- let elems_for_smallest_tree = tree:: leaf_adic :: < F > ( ) * 2 ;
60
-
61
- let row_num: usize = elems_for_smallest_tree;
62
- let msg_size: usize = ( 1 << poly_variables) / row_num;
63
-
64
- ( row_num, msg_size)
65
- }
66
-
67
66
pub fn new < F : Field > ( num_variables : usize , code_instance : OrionCode ) -> OrionResult < Self > {
68
67
let ( _, msg_size) = Self :: row_col_from_variables :: < F > ( num_variables) ;
69
68
if msg_size != code_instance. msg_len ( ) {
@@ -91,28 +90,6 @@ impl OrionPublicParams {
91
90
}
92
91
}
93
92
94
- pub fn code_len ( & self ) -> usize {
95
- self . code_instance . code_len ( )
96
- }
97
-
98
- pub fn query_complexity ( & self , soundness_bits : usize ) -> usize {
99
- // NOTE: use Ligero (AHIV22) or Avg-case dist to a code (BKS18)
100
- // version of avg case dist in unique decoding technique.
101
- let avg_case_dist = self . code_instance . hamming_weight ( ) / 3f64 ;
102
- let sec_bits = -( 1f64 - avg_case_dist) . log2 ( ) ;
103
-
104
- ( soundness_bits as f64 / sec_bits) . ceil ( ) as usize
105
- }
106
-
107
- pub fn proximity_repetition_num ( & self , soundness_bits : usize , field_size_bits : usize ) -> usize {
108
- // NOTE: use Ligero (AHIV22) or Avg-case dist to a code (BKS18)
109
- // version of avg case dist in unique decoding technique.
110
- // Here is the probability union bound
111
- let code_len_over_f_bits = field_size_bits - self . code_instance . code_len ( ) . ilog2 ( ) as usize ;
112
-
113
- ( soundness_bits as f64 / code_len_over_f_bits as f64 ) . ceil ( ) as usize
114
- }
115
-
116
93
pub fn commit < F , ComPackF > (
117
94
& self ,
118
95
poly : & MultiLinearPoly < F > ,
@@ -146,17 +123,18 @@ impl OrionPublicParams {
146
123
drop ( scratch) ;
147
124
148
125
// NOTE: packed codeword buffer and encode over packed field
149
- let mut packed_interleaved_codewords = vec ! [ ComPackF :: ZERO ; packed_rows * self . code_len( ) ] ;
126
+ let mut packed_interleaved_codewords =
127
+ vec ! [ ComPackF :: ZERO ; packed_rows * self . codeword_len( ) ] ;
150
128
packed_evals
151
129
. chunks ( msg_size)
152
- . zip ( packed_interleaved_codewords. chunks_mut ( self . code_len ( ) ) )
130
+ . zip ( packed_interleaved_codewords. chunks_mut ( self . codeword_len ( ) ) )
153
131
. try_for_each ( |( evals, codeword) | {
154
132
self . code_instance . encode_in_place ( evals, codeword)
155
133
} ) ?;
156
134
drop ( packed_evals) ;
157
135
158
136
// NOTE: transpose codeword s.t., the matrix has codewords being columns
159
- let mut scratch = vec ! [ ComPackF :: ZERO ; packed_rows * self . code_len ( ) ] ;
137
+ let mut scratch = vec ! [ ComPackF :: ZERO ; packed_rows * self . codeword_len ( ) ] ;
160
138
transpose_in_place ( & mut packed_interleaved_codewords, & mut scratch, packed_rows) ;
161
139
drop ( scratch) ;
162
140
@@ -225,9 +203,8 @@ impl OrionPublicParams {
225
203
226
204
// NOTE: draw random linear combination out
227
205
// and compose proximity response(s) of tensor code IOP based PCS
228
- let proximity_repetitions =
229
- self . proximity_repetition_num ( PCS_SOUNDNESS_BITS , EvalF :: FIELD_SIZE ) ;
230
- let mut proximity_rows = vec ! [ vec![ EvalF :: ZERO ; msg_size] ; proximity_repetitions] ;
206
+ let proximity_test_num = self . proximity_repetitions :: < EvalF > ( PCS_SOUNDNESS_BITS ) ;
207
+ let mut proximity_rows = vec ! [ vec![ EvalF :: ZERO ; msg_size] ; proximity_test_num] ;
231
208
232
209
proximity_rows. iter_mut ( ) . for_each ( |row_buffer| {
233
210
let random_coeffs = transcript. generate_challenge_field_elements ( row_num) ;
@@ -238,6 +215,7 @@ impl OrionPublicParams {
238
215
. zip ( row_buffer. iter_mut ( ) )
239
216
. for_each ( |( p_col, res) | * res = luts. lookup_and_sum ( p_col) ) ;
240
217
} ) ;
218
+ drop ( luts) ;
241
219
242
220
// NOTE: working on evaluation on top of evaluation response
243
221
let mut scratch = vec ! [ EvalF :: ZERO ; msg_size] ;
@@ -246,6 +224,7 @@ impl OrionPublicParams {
246
224
& point[ ..num_of_vars_in_msg] ,
247
225
& mut scratch,
248
226
) ;
227
+ drop ( scratch) ;
249
228
250
229
// NOTE: MT opening for point queries
251
230
let leaf_range = row_num / tree:: leaf_adic :: < F > ( ) ;
@@ -254,7 +233,7 @@ impl OrionPublicParams {
254
233
let query_openings = query_indices
255
234
. iter ( )
256
235
. map ( |qi| {
257
- let index = * qi % self . code_len ( ) ;
236
+ let index = * qi % self . codeword_len ( ) ;
258
237
let left = index * leaf_range;
259
238
let right = left + leaf_range - 1 ;
260
239
@@ -305,8 +284,7 @@ impl OrionPublicParams {
305
284
306
285
// NOTE: working on proximity responses, draw random linear combinations
307
286
// then draw query points from fiat shamir transcripts
308
- let proximity_test_num =
309
- self . proximity_repetition_num ( PCS_SOUNDNESS_BITS , EvalF :: FIELD_SIZE ) ;
287
+ let proximity_test_num = self . proximity_repetitions :: < EvalF > ( PCS_SOUNDNESS_BITS ) ;
310
288
let random_linear_combinations: Vec < Vec < EvalF > > = ( 0 ..proximity_test_num)
311
289
. map ( |_| transcript. generate_challenge_field_elements ( row_num) )
312
290
. collect ( ) ;
@@ -320,7 +298,7 @@ impl OrionPublicParams {
320
298
. iter ( )
321
299
. zip ( proof. query_openings . iter ( ) )
322
300
. all ( |( & qi, range_path) | {
323
- let index = qi % self . code_len ( ) ;
301
+ let index = qi % self . codeword_len ( ) ;
324
302
range_path. verify ( commitment) && index == range_path. left / leaf_range
325
303
} ) ;
326
304
if !mt_consistency {
@@ -363,7 +341,7 @@ impl OrionPublicParams {
363
341
. iter ( )
364
342
. zip ( packed_interleaved_alphabets. iter ( ) )
365
343
. all ( |( & qi, interleaved_alphabet) | {
366
- let index = qi % self . code_len ( ) ;
344
+ let index = qi % self . codeword_len ( ) ;
367
345
let alphabet = luts. lookup_and_sum ( interleaved_alphabet) ;
368
346
alphabet == codeword[ index]
369
347
} )
0 commit comments