Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit 6b4a6f3

Browse files
committed
Public input processing enabled #65
1 parent 13531d8 commit 6b4a6f3

File tree

2 files changed

+23
-46
lines changed

2 files changed

+23
-46
lines changed

include/nil/blueprint/transpiler/recursive_verifier_generator.hpp

+8-36
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ namespace nil {
6565
using assignment_table_type = typename PlaceholderParams::assignment_table_type;
6666

6767
// TODO: Move logic to utils.hpp. It's similar to EVM verifier generator
68-
static std::string zero_indices(columns_rotations_type col_rotations){
68+
static std::string zero_indices(columns_rotations_type col_rotations, std::size_t permutation_size){
6969
std::vector<std::size_t> zero_indices;
7070
std::uint16_t fixed_values_points = 0;
7171
std::stringstream result;
@@ -90,16 +90,17 @@ namespace nil {
9090
for(; i < PlaceholderParams::witness_columns + PlaceholderParams::public_input_columns; i++){
9191
zero_indices[i] = sum + zero_indices[i];
9292
sum += col_rotations[i].size();
93-
if( i != 0) result << ", ";
94-
result << zero_indices[i];
9593
}
9694

9795
sum = 0;
9896
for(; i < PlaceholderParams::total_columns; i++){
9997
zero_indices[i] = sum + zero_indices[i];
10098
sum += col_rotations[i].size() + 1;
101-
if( i != 0) result << ", ";
102-
result << zero_indices[i];
99+
}
100+
101+
for( i = 0; i < PlaceholderParams::total_columns; i++){
102+
if( i != 0 ) result << ", ";
103+
result << zero_indices[i] + 4 * permutation_size + 6;
103104
}
104105
return result.str();
105106
}
@@ -995,36 +996,7 @@ namespace nil {
995996
}
996997
prepare_U_V_str << "\n";
997998
}
998-
/* for(std::size_t i = 0; i < unique_points.size(); i++){
999-
prepare_U_V_str << "\tV[" << i << "] = getV"<< unique_points[i].size() << "(";
1000-
for(std::size_t j = 0; j < unique_points[i].size(); j++ ){
1001-
if(j != 0) prepare_U_V_str << ", ";
1002-
prepare_U_V_str << "singles[" << singles[unique_points[i][j]] << "]";
1003-
}
1004-
prepare_U_V_str << ");" << std::endl << std::endl;
1005-
}
1006-
for(std::size_t ind = 0; ind < point_ids.size(); ind++){
1007-
std::size_t i = point_ids.size() - 1 - ind;
1008-
prepare_U_V_str << "\ttmp = getU"<< unique_points[point_ids[i]].size() << "(";
1009-
for(std::size_t j = 0; j < unique_points[point_ids[i]].size(); j++ ){
1010-
if(j != 0) prepare_U_V_str << ", ";
1011-
prepare_U_V_str << "singles[" << singles[unique_points[point_ids[i]][j]] << "]";
1012-
}
1013-
for(std::size_t j = 0; j < unique_points[point_ids[i]].size(); j++ ){
1014-
prepare_U_V_str << ", ";
1015-
if( j == unique_points[point_ids[i]].size() - 1 )
1016-
prepare_U_V_str << "proof.z[z_ind]";
1017-
else
1018-
prepare_U_V_str << "proof.z[z_ind - "<< unique_points[point_ids[i]].size() - j - 1 <<" ]";
1019-
}
1020-
prepare_U_V_str << ");" << std::endl;
1021-
prepare_U_V_str << "\tz_ind = z_ind - " << unique_points[point_ids[i]].size() << ";" << std::endl;
1022-
for(std::size_t j = 0; j < unique_points[point_ids[i]].size(); j++ ){
1023-
prepare_U_V_str << "\tcombined_U[" << point_ids[i] << "][" << j << "] = combined_U[" << point_ids[i] << "][" << j << "] + tmp[" << j << "] * theta_acc;" << std::endl;
1024-
}
1025-
prepare_U_V_str << "\ttheta_acc = theta_acc * challenges.lpc_theta;" << std::endl;
1026-
}
1027-
*/
999+
10281000
std::stringstream compute_combined_y;
10291001
for(std::size_t i = 0; i < point_ids.size(); i++){
10301002
/*y[0] = y[0] * challenges.lpc_theta;
@@ -1094,7 +1066,7 @@ namespace nil {
10941066
reps["$FINAL_POLYNOMIAL_SIZE$"] = to_string(std::pow(2, std::log2(fri_params.max_degree + 1) - fri_params.r + 1) - 2);
10951067
reps["$LAMBDA$"] = to_string(lambda);
10961068
reps["$PERMUTATION_SIZE$"] = to_string(permutation_size);
1097-
reps["$ZERO_INDICES$"] = zero_indices(common_data.columns_rotations);
1069+
reps["$ZERO_INDICES$"] = zero_indices(common_data.columns_rotations, permutation_size);
10981070
reps["$TOTAL_COLUMNS$"] = to_string(arithmetization_params::total_columns);
10991071
reps["$ROWS_LOG$"] = to_string(log2(rows_amount));
11001072
reps["$ROWS_AMOUNT$"] = to_string(rows_amount);

include/nil/blueprint/transpiler/templates/recursive_verifier.hpp

+15-10
Original file line numberDiff line numberDiff line change
@@ -620,23 +620,28 @@ typedef __attribute__((ext_vector_type(2)))
620620
precomputed_values_type precomputed_values;
621621
std::tie(precomputed_values.l0, precomputed_values.Z_at_xi) = xi_polys(challenges.xi);
622622
623+
//Check public input
624+
std::size_t cur = 0;
625+
for( std::size_t i = 0; i < public_input_amount; i++){
626+
pallas::base_field_type::value_type Omega(1);
627+
pallas::base_field_type::value_type result(0);
628+
for( std::size_t j = 0; j < public_input_sizes[i]; j++){
629+
result += public_input[cur] * Omega / (challenges.xi - Omega);
630+
Omega *= omega;
631+
cur++;
632+
}
633+
__builtin_assigner_exit_check(rows_amount * proof.z[zero_indices[witness_amount + i]] == precomputed_values.Z_at_xi * result);
634+
}
635+
623636
std::array<pallas::base_field_type::value_type, 8> F;// = {0,0,0,0,0,0,0,0};
624-
F[0] = pallas::base_field_type::value_type(0);
625-
F[1] = pallas::base_field_type::value_type(0);
626-
F[2] = pallas::base_field_type::value_type(0);
627-
F[3] = pallas::base_field_type::value_type(0);
628-
F[4] = pallas::base_field_type::value_type(0);
629-
F[5] = pallas::base_field_type::value_type(0);
630-
F[6] = pallas::base_field_type::value_type(0);
631-
F[7] = pallas::base_field_type::value_type(0);
632637
633638
// Call permutation argument
634639
placeholder_permutation_argument_input_type perm_arg_input;
635640
perm_arg_input.thetas[0] = challenges.perm_beta;
636641
perm_arg_input.thetas[1] = challenges.perm_gamma;
637642
638643
for( std::size_t i = 0; i < permutation_size; i++ ){
639-
perm_arg_input.xi_values[i] = proof.z[4*permutation_size + 6 + zero_indices[i]];
644+
perm_arg_input.xi_values[i] = proof.z[zero_indices[i]];
640645
perm_arg_input.id_perm[i] = proof.z[2*i];
641646
perm_arg_input.sigma_perm[i] = proof.z[2*permutation_size + 2*i];
642647
}
@@ -666,7 +671,7 @@ typedef __attribute__((ext_vector_type(2)))
666671
constraints = calculate_constraints(proof.z);
667672
668673
for( std::size_t i = 0; i < gates_amount; i++ ){
669-
selectors[i] = proof.z[4 * permutation_size + 6 + zero_indices[witness_amount + public_input_amount + constant_amount + gates_selector_indices[i]]];
674+
selectors[i] = proof.z[zero_indices[witness_amount + public_input_amount + constant_amount + gates_selector_indices[i]]];
670675
}
671676
672677
F[7] = gate_argument_verifier(

0 commit comments

Comments
 (0)