@@ -785,15 +785,15 @@ namespace nil {
785
785
std::string eta_point_verification_code () {
786
786
std::stringstream result;
787
787
auto fixed_poly_values = _common_data.commitment_scheme_data ;
788
- std::size_t poly_points = 2 ;
789
-
788
+ using eta_hash = crypto3::hashes::keccak_1600<256 >;
789
+ using field_element_type = nil::crypto3::marshalling::types::field_element<
790
+ nil::marshalling::field_type<nil::marshalling::option::big_endian>,
791
+ typename PlaceholderParams::field_type::value_type>;
792
+
790
793
if (fixed_poly_values.size () == 0 )
791
794
return " " ;
792
-
793
- result << " \t\t {" << std::endl;
794
- result << " \t\t\t uint256 poly_at_eta;" << std::endl;
795
795
796
- result << " \t\t\t /* 1 - 2*permutation_size */" << std::endl;
796
+ result << " \t\t\t /// * 1 - 2*permutation_size */" << std::endl;
797
797
std::vector<std::uint8_t > eta_buf;
798
798
799
799
std::size_t poly_points = 2 *_permutation_size;
@@ -806,7 +806,7 @@ namespace nil {
806
806
std::array<std::uint8_t , 0 > empty;
807
807
auto writer = eta_buf.begin ();
808
808
809
- result << " \t\t /* eta points check */" << std::endl;
809
+ result << " \t\t /// * eta points check */" << std::endl;
810
810
result << " \t\t {" << std::endl;
811
811
result << " \t\t\t uint256[" << poly_points << " ] memory points;" << std::endl;
812
812
@@ -818,8 +818,10 @@ namespace nil {
818
818
819
819
poly_points = 2 ;
820
820
while (j < 2 *_permutation_size) {
821
- result << " \t\t\t poly_at_eta = basic_marshalling.get_uint256_be(blob, " << point_offset+(poly_points-1 )*32 << " );" << " // " << i << std::endl;
822
- result << " \t\t\t if(poly_at_eta != " << std::showbase<< std::hex << fixed_poly_values[0 ][i] << " ) return false;" << std::endl;
821
+ result << " \t\t\t points[" << i << " ] = basic_marshalling.get_uint256_be(blob," ;
822
+ result << point_offset + (poly_points-1 )*32 << " );" << std::endl;
823
+ field_element_type value (fixed_poly_values[0 ][i]);
824
+ value.write (writer, 32 );
823
825
point_offset += 32 *poly_points;
824
826
++i;
825
827
++j;
@@ -829,20 +831,23 @@ namespace nil {
829
831
830
832
j = 0 ;
831
833
while (j < 2 ) {
832
- result << " \t\t\t poly_at_eta = basic_marshalling.get_uint256_be(blob, " << point_offset+(poly_points-1 )*32 << " );" << " // " << i << std::endl;
833
- result << " \t\t\t if(poly_at_eta != " << std::showbase<< std::hex << fixed_poly_values[0 ][i] << " ) return false;" << std::endl;
834
+ result << " \t\t\t points[" << i << " ] = basic_marshalling.get_uint256_be(blob," ;
835
+ result << point_offset + (poly_points-1 )*32 << " );" << std::endl;
836
+ field_element_type value (fixed_poly_values[0 ][i]);
837
+ value.write (writer, 32 );
834
838
point_offset += 32 *poly_points;
835
839
++i;
836
840
++j;
837
841
}
838
842
839
843
std::size_t column_rotation_offset = PlaceholderParams::witness_columns + PlaceholderParams::public_input_columns;
840
- result << " \t\t\t /* 3 - constant columns */" << std::endl;
841
844
j = 0 ;
842
845
while (j < PlaceholderParams::arithmetization_params::constant_columns) {
843
846
poly_points = _common_data.columns_rotations [column_rotation_offset + j].size ()+1 ;
844
- result << " \t\t\t poly_at_eta = basic_marshalling.get_uint256_be(blob, " << point_offset+(poly_points-1 )*32 << " );" << " // " << i << std::endl;
845
- result << " \t\t\t if(poly_at_eta != " << std::showbase<< std::hex << fixed_poly_values[0 ][i] << " ) return false;" << std::endl;
847
+ result << " \t\t\t points[" << i << " ] = basic_marshalling.get_uint256_be(blob," ;
848
+ result << point_offset + (poly_points-1 )*32 << " );" << std::endl;
849
+ field_element_type value (fixed_poly_values[0 ][i]);
850
+ value.write (writer, 32 );
846
851
point_offset += 32 *poly_points;
847
852
++i;
848
853
++j;
@@ -852,15 +857,17 @@ namespace nil {
852
857
j = 0 ;
853
858
while (j < PlaceholderParams::arithmetization_params::selector_columns) {
854
859
poly_points = _common_data.columns_rotations [column_rotation_offset + j].size ()+1 ;
855
- result << " \t\t\t poly_at_eta = basic_marshalling.get_uint256_be(blob, " << point_offset+(poly_points-1 )*32 << " );" << " // " << i << std::endl;
856
- result << " \t\t\t if(poly_at_eta != " << std::showbase<< std::hex << fixed_poly_values[0 ][i] << " ) return false;" << std::endl;
860
+ result << " \t\t\t points[" << i << " ] = basic_marshalling.get_uint256_be(blob," ;
861
+ result << point_offset + (poly_points-1 )*32 << " );" << std::endl;
862
+ field_element_type value (fixed_poly_values[0 ][i]);
863
+ value.write (writer, 32 );
857
864
point_offset += 32 *(poly_points);
858
865
++i;
859
866
++j;
860
867
}
861
868
862
869
eta_hash::digest_type hash_result = crypto3::hash<eta_hash>(eta_buf);
863
- result << " \t\t\t /* Check keccak(points) */ " << std::endl;
870
+ result << " \t\t\t // Check keccak(points) " << std::endl;
864
871
result << " \t\t\t if ( bytes32(0x" << std::to_string (hash_result).data () << " ) != keccak256(abi.encode(points))) {" << std::endl;
865
872
result << " \t\t\t\t return false;" << std::endl;
866
873
result << " \t\t\t }" << std::endl;
0 commit comments