@@ -60,74 +60,19 @@ namespace nil {
60
60
const common_data_type<PlaceholderParams> &common_data,
61
61
const typename PlaceholderParams::commitment_scheme_type& lpc_scheme,
62
62
std::size_t permutation_size,
63
+ std::size_t quotient_polys,
64
+ std::size_t lookup_polys,
63
65
bool use_lookups
64
66
){
65
67
std::set<std::string> unique_points;
66
68
std::vector<std::string> points;
67
69
68
- for (std::size_t i = 0 ; i < permutation_size*2 ; i++){
69
- points.push_back (rot_string (0 ) + " & _etha& " );
70
- }
71
- unique_points.insert (rot_string (0 ) + " & _etha& " );
72
- points.push_back (rot_string (0 ) + " & " + rot_string (1 ) + " & _etha& " );
73
- points.push_back (rot_string (0 ) + " & " + rot_string (1 ) + " & _etha& " );
74
- unique_points.insert (rot_string (0 ) + " & " + rot_string (1 ) + " & _etha& " );
75
-
76
- for (std::size_t i = 0 ; i < PlaceholderParams::constant_columns; i++){
77
- std::stringstream str;
78
- for (auto j:common_data.columns_rotations [i + PlaceholderParams::witness_columns + PlaceholderParams::public_input_columns]){
79
- str << rot_string (j) << " & " ;
80
- }
81
- str << " _etha& " ;
82
- unique_points.insert (str.str ());
83
- points.push_back (str.str ());
84
- }
85
-
86
- for (std::size_t i = 0 ; i < PlaceholderParams::selector_columns; i++){
87
- std::stringstream str;
88
- for (auto j:common_data.columns_rotations [i + PlaceholderParams::witness_columns + PlaceholderParams::public_input_columns + PlaceholderParams::constant_columns]){
89
- str << rot_string (j) << " & " ;
90
- }
91
- str << " _etha& " ;
92
- unique_points.insert (str.str ());
93
- points.push_back (str.str ());
94
- }
95
-
96
- for (std::size_t i = 0 ; i < PlaceholderParams::witness_columns; i++){
97
- std::stringstream str;
98
- for (auto j:common_data.columns_rotations [i]){
99
- str << rot_string (j) << " & " ;
100
- }
101
- unique_points.insert (str.str ());
102
- points.push_back (str.str ());
103
- }
104
-
105
- for (std::size_t i = 0 ; i < PlaceholderParams::public_input_columns; i++){
106
- std::stringstream str;
107
- for (auto j:common_data.columns_rotations [i + PlaceholderParams::witness_columns]){
108
- str << rot_string (j) << " & " ;
109
- }
110
- unique_points.insert (str.str ());
111
- points.push_back (str.str ());
112
- }
113
-
114
- unique_points.insert (rot_string (0 ) + " & " + rot_string (1 ) + " & " );// Permutation
115
- unique_points.insert (rot_string (0 ) + " & " );// Quotient
116
- if (use_lookups)
117
- unique_points.insert (rot_string (0 ) + " & " + rot_string (1 ) + " & " + rot_string (common_data.usable_rows_amount ) + " & " ); // Lookups
118
-
119
- std::size_t permutation_point_id;
120
- std::size_t quotient_point_id;
121
- std::size_t lookup_point_id;
122
- std::size_t j = 0 ;
123
- for ( const auto &unique_point:unique_points){
124
- if ( unique_point == rot_string (0 ) + " & " ) quotient_point_id = j;
125
- if ( unique_point == rot_string (0 ) + " & " + rot_string (1 ) + " & " + rot_string (common_data.usable_rows_amount ) + " & " ) lookup_point_id = j;
126
- if ( unique_point == rot_string (0 ) + " & " + rot_string (1 ) + " & " ) permutation_point_id = j;
127
- j++;
128
- }
70
+ auto [z_points_indices, singles_strs, singles_map, poly_ids] = calculate_unique_points<PlaceholderParams, common_data_type<PlaceholderParams>>(
71
+ common_data, permutation_size, use_lookups, quotient_polys, lookup_polys,
72
+ " evm" // Generator mode
73
+ );
129
74
130
- std::stringstream points_ids;
75
+ /* std::stringstream points_ids;
131
76
for(std::size_t i = 0; i < points.size(); i++){
132
77
std::size_t j = 0;
133
78
for(const auto &unique_point:unique_points){
@@ -137,24 +82,30 @@ namespace nil {
137
82
}
138
83
j++;
139
84
}
140
- }
85
+ }*/
141
86
142
87
std::stringstream points_initializer;
143
88
std::size_t i = 0 ;
144
- for (const auto & point: unique_points){
145
- points_initializer << " \t\t result[" << i << " ] = new uint256[](" << std::count (point.begin (), point.end (), ' &' ) << " );" << std::endl;
146
- std::size_t prev = 0 ;
147
- std::size_t found = point.find (" & " );
148
- std::size_t j = 0 ;
149
- while (found!=std::string::npos){
150
- points_initializer << " \t\t result[" << i << " ][" << j << " ] = " << point.substr (prev, found-prev) << " ;" << std::endl;
151
- prev = found + 2 ;
152
- found = point.find (" & " ,prev);
153
- j++;
154
- }
89
+
90
+ for (const auto & point: singles_strs){
91
+ points_initializer << " \t\t result[" << i << " ] = " << point << " ;" << std::endl;
155
92
i++;
156
93
}
157
94
95
+ std::stringstream points_ids;
96
+ for ( const auto & point_id: z_points_indices){
97
+ points_ids << std::hex << std::setw (2 ) << std::setfill (' 0' ) << point_id;
98
+ }
99
+
100
+ std::stringstream poly_ids_str;
101
+ std::stringstream poly_points_num;
102
+ for (i = 0 ; i < poly_ids.size (); i++){
103
+ poly_points_num << std::hex << std::setw (4 ) << std::setfill (' 0' ) << poly_ids[i].size ();
104
+ for (std::size_t j = 0 ; j < poly_ids[i].size (); j++){
105
+ poly_ids_str << std::hex << std::setw (4 ) << std::setfill (' 0' ) << poly_ids[i][j] * 0x40 ;
106
+ }
107
+ }
108
+
158
109
std::vector<std::uint8_t > init_blob = {};
159
110
nil::crypto3::zk::transcript::fiat_shamir_heuristic_sequential<typename PlaceholderParams::transcript_hash_type> transcript (init_blob);
160
111
transcript (common_data.vk .constraint_system_with_params_hash );
@@ -167,14 +118,13 @@ namespace nil {
167
118
replacements[" $D0_SIZE$" ] = to_string (fri_params.D [0 ]->m );
168
119
replacements[" $D0_OMEGA$" ] = to_string (fri_params.D [0 ]->get_domain_element (1 ));
169
120
replacements[" $MAX_DEGREE$" ] = to_string (fri_params.max_degree );
170
- replacements[" $UNIQUE_POINTS$" ] = to_string (unique_points.size ());
171
- replacements[" $DIFFERENT_POINTS$" ] = to_string (unique_points.size ());
172
- replacements[" $PERMUTATION_POINTS_ID$" ] = to_string (permutation_point_id);
173
- replacements[" $QUOTIENT_POINTS_ID$" ] = to_string (quotient_point_id);
174
- replacements[" $LOOKUP_POINTS_ID$" ] = to_string (lookup_point_id);
121
+ replacements[" $UNIQUE_POINTS$" ] = to_string (singles_strs.size ());
122
+ replacements[" $DIFFERENT_POINTS$" ] = to_string (singles_strs.size ());
175
123
replacements[" $POINTS_IDS$" ] = points_ids.str ();
124
+ replacements[" $POLY_IDS$" ] = poly_ids_str.str ();
125
+ replacements[" $POLY_POINTS_NUM$" ] = poly_points_num.str ();
176
126
replacements[" $POINTS_INITIALIZATION$" ] = points_initializer.str ();
177
- replacements[" $ETHA $" ] = to_string (etha);
127
+ replacements[" $ETA $" ] = to_string (etha);
178
128
if ( PlaceholderParams::commitment_scheme_type::fri_type::use_grinding){
179
129
auto params = PlaceholderParams::commitment_scheme_type::fri_type::grinding_type::get_params ();
180
130
uint32_t mask_value = params.template get <uint32_t >(" mask" , 0 );
0 commit comments