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

Commit 236a5cb

Browse files
committed
Master branch merged to #65
2 parents da1065c + f206e94 commit 236a5cb

File tree

5 files changed

+633
-79
lines changed

5 files changed

+633
-79
lines changed

include/nil/blueprint/transpiler/evm_verifier_gen.hpp

+24-17
Original file line numberDiff line numberDiff line change
@@ -785,15 +785,15 @@ namespace nil {
785785
std::string eta_point_verification_code() {
786786
std::stringstream result;
787787
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+
790793
if (fixed_poly_values.size() == 0)
791794
return "";
792-
793-
result << "\t\t{" << std::endl;
794-
result << "\t\t\tuint256 poly_at_eta;" << std::endl;
795795

796-
result << "\t\t\t/* 1 - 2*permutation_size */" << std::endl;
796+
result << "\t\t\t///* 1 - 2*permutation_size */" << std::endl;
797797
std::vector<std::uint8_t> eta_buf;
798798

799799
std::size_t poly_points = 2*_permutation_size;
@@ -806,7 +806,7 @@ namespace nil {
806806
std::array<std::uint8_t, 0> empty;
807807
auto writer = eta_buf.begin();
808808

809-
result << "\t\t/* eta points check */" << std::endl;
809+
result << "\t\t///* eta points check */" << std::endl;
810810
result << "\t\t{" << std::endl;
811811
result << "\t\t\tuint256[" << poly_points << "] memory points;" << std::endl;
812812

@@ -818,8 +818,10 @@ namespace nil {
818818

819819
poly_points = 2;
820820
while (j < 2*_permutation_size) {
821-
result << "\t\t\tpoly_at_eta = basic_marshalling.get_uint256_be(blob, " << point_offset+(poly_points-1)*32 << ");" << "// " << i << std::endl;
822-
result << "\t\t\tif(poly_at_eta != " << std::showbase<< std::hex << fixed_poly_values[0][i] << ") return false;" << std::endl;
821+
result << "\t\t\tpoints[" << 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);
823825
point_offset += 32*poly_points;
824826
++i;
825827
++j;
@@ -829,20 +831,23 @@ namespace nil {
829831

830832
j = 0;
831833
while (j < 2) {
832-
result << "\t\t\tpoly_at_eta = basic_marshalling.get_uint256_be(blob, " << point_offset+(poly_points-1)*32 << ");" << "// " << i << std::endl;
833-
result << "\t\t\tif(poly_at_eta != " << std::showbase<< std::hex << fixed_poly_values[0][i] << ") return false;" << std::endl;
834+
result << "\t\t\tpoints[" << 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);
834838
point_offset += 32*poly_points;
835839
++i;
836840
++j;
837841
}
838842

839843
std::size_t column_rotation_offset = PlaceholderParams::witness_columns + PlaceholderParams::public_input_columns;
840-
result << "\t\t\t/* 3 - constant columns */" << std::endl;
841844
j = 0;
842845
while (j < PlaceholderParams::arithmetization_params::constant_columns) {
843846
poly_points = _common_data.columns_rotations[column_rotation_offset + j].size()+1;
844-
result << "\t\t\tpoly_at_eta = basic_marshalling.get_uint256_be(blob, " << point_offset+(poly_points-1)*32 << ");" << "// " << i << std::endl;
845-
result << "\t\t\tif(poly_at_eta != " << std::showbase<< std::hex << fixed_poly_values[0][i] << ") return false;" << std::endl;
847+
result << "\t\t\tpoints[" << 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);
846851
point_offset += 32*poly_points;
847852
++i;
848853
++j;
@@ -852,15 +857,17 @@ namespace nil {
852857
j = 0;
853858
while (j < PlaceholderParams::arithmetization_params::selector_columns) {
854859
poly_points = _common_data.columns_rotations[column_rotation_offset + j].size()+1;
855-
result << "\t\t\tpoly_at_eta = basic_marshalling.get_uint256_be(blob, " << point_offset+(poly_points-1)*32 << ");" << "// " << i << std::endl;
856-
result << "\t\t\tif(poly_at_eta != " << std::showbase<< std::hex << fixed_poly_values[0][i] << ") return false;" << std::endl;
860+
result << "\t\t\tpoints[" << 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);
857864
point_offset += 32*(poly_points);
858865
++i;
859866
++j;
860867
}
861868

862869
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;
864871
result << "\t\t\tif ( bytes32(0x" << std::to_string(hash_result).data() << ") != keccak256(abi.encode(points))) {" << std::endl;
865872
result << "\t\t\t\treturn false;" << std::endl;
866873
result << "\t\t\t}" << std::endl;

include/nil/blueprint/transpiler/lpc_scheme_gen.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ namespace nil {
9090
transcript(common_data.vk.fixed_values_commitment);
9191
auto etha = transcript.template challenge<typename PlaceholderParams::field_type>();
9292

93-
auto fri_params = lpc_scheme.get_fri_params();
93+
auto fri_params = lpc_scheme.get_commitment_params();
9494
replacements["$R$"] = to_string(fri_params.r);
9595
replacements["$LAMBDA$"] = to_string(PlaceholderParams::commitment_scheme_type::fri_type::lambda);
9696
replacements["$D0_SIZE$"] = to_string(fri_params.D[0]->m);

include/nil/blueprint/transpiler/recursive_verifier_generator.hpp

+14
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
#include <nil/crypto3/zk/math/expression_evaluator.hpp>
4343

4444
#include<nil/blueprint/transpiler/templates/recursive_verifier.hpp>
45+
<<<<<<< HEAD
46+
=======
47+
48+
>>>>>>> f206e94a0635f5ba293f7decb9e08ffe08503bc1
4549
namespace nil {
4650
namespace blueprint {
4751
template<typename PlaceholderParams>
@@ -419,6 +423,7 @@ namespace nil {
419423
const constraint_system_type &constraint_system,
420424
const common_data_type &common_data,
421425
const commitment_scheme_type &commitment_scheme,
426+
<<<<<<< HEAD
422427
std::size_t permutation_size,
423428
const std::array<std::size_t, arithmetization_params::public_input_columns> public_input_sizes
424429
){
@@ -691,6 +696,8 @@ namespace nil {
691696
result = replace_all(result, reps);
692697
return result;
693698
=======
699+
=======
700+
>>>>>>> f206e94a0635f5ba293f7decb9e08ffe08503bc1
694701
std::size_t permutation_size
695702
){
696703
if constexpr(std::is_same<
@@ -794,10 +801,17 @@ namespace nil {
794801
}
795802
BOOST_ASSERT_MSG(false, "unsupported commitment scheme type");
796803
return "unsupported commitment scheme type";
804+
<<<<<<< HEAD
797805
>>>>>>> f302960... Add recursive generator, update EVM verifier #39
806+
=======
807+
>>>>>>> f206e94a0635f5ba293f7decb9e08ffe08503bc1
798808
}
799809
};
800810
}
801811
}
802812

813+
<<<<<<< HEAD
814+
#endif // CRYPTO3_RECURSIVE_VERIFIER_GENERATOR_HPP
815+
=======
803816
#endif // CRYPTO3_RECURSIVE_VERIFIER_GENERATOR_HPP
817+
>>>>>>> f206e94a0635f5ba293f7decb9e08ffe08503bc1

0 commit comments

Comments
 (0)