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

Commit

Permalink
Crypto3 and libs/actor/zk updated #83
Browse files Browse the repository at this point in the history
  • Loading branch information
ETatuzova authored and x-mass committed Apr 30, 2024
1 parent 6c92fb0 commit 0052ec3
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 29 deletions.
10 changes: 5 additions & 5 deletions bin/proof-generator/include/nil/proof-generator/arg_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ namespace nil {
boost::log::trivial::severity_level log_level = boost::log::trivial::severity_level::info;
bool skip_verification = false;
bool verification_only = false;
CurvesVariant elliptic_curve_type = type_identity<nil::crypto3::algebra::curves::pallas>{};
HashesVariant hash_type = type_identity<nil::crypto3::hashes::keccak_1600<256>>{};
LambdaParam lambda = all_lambda_params[0];
GrindParam grind = all_grind_params[0];
std::size_t component_constant_columns = 5;
CurvesVariant elliptic_curve_type = type_identity<nil::crypto3::algebra::curves::pallas> {};
HashesVariant hash_type;
columns_params columns = all_columns_params[0];
lambda_param lambda = all_lambda_params[0];
grind_param grind = all_grind_params[0];
std::size_t expand_factor = 2;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
#include <tuple>

#include <nil/crypto3/algebra/curves/pallas.hpp>
#include <nil/crypto3/algebra/curves/vesta.hpp>

#include <nil/crypto3/hash/keccak.hpp>
#include <nil/crypto3/hash/poseidon.hpp>
#include <nil/crypto3/hash/sha2.hpp>

#include <nil/proof-generator/non_type_arithmetization_params.hpp>

Expand All @@ -39,16 +42,17 @@ namespace nil {
// Add more params as needed.
};

using CurveTypes = std::tuple<nil::crypto3::algebra::curves::pallas
// Add more curves as needed.
>;
using CurveTypes = std::tuple<
nil::crypto3::algebra::curves::pallas
// Add more curves as needed.
>;

using HashTypes = std::tuple<
nil::crypto3::hashes::keccak_1600<256>,
nil::crypto3::hashes::poseidon<nil::crypto3::hashes::detail::mina_poseidon_policy<
typename nil::crypto3::algebra::curves::pallas::base_field_type>>
nil::crypto3::hashes::sha2<256>,
nil::crypto3::hashes::poseidon<nil::crypto3::hashes::detail::mina_poseidon_policy<nil::crypto3::algebra::curves::pallas::base_field_type>>
// Add more hashes as needed.
>;
>;

} // namespace proof_generator
} // namespace nil
Expand Down
4 changes: 2 additions & 2 deletions bin/proof-generator/include/nil/proof-generator/prover.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ namespace nil {
using TTypeBase = nil::marshalling::field_type<Endianness>;
using ConstraintMarshalling =
nil::crypto3::marshalling::types::plonk_constraint_system<TTypeBase, ConstraintSystem>;

{
auto marshalled_value = detail::decode_marshalling_from_file<ConstraintMarshalling>(circuit_file_);
if (!marshalled_value) {
Expand All @@ -322,8 +323,7 @@ namespace nil {
nil::crypto3::marshalling::types::make_assignment_table<Endianness, AssignmentTable>(
*marshalled_table
);
public_inputs_ = assignment_table.public_inputs();
table_description_.emplace(table_description);
table_description_ = table_description;

// Lambdas and grinding bits should be passed threw preprocessor directives
std::size_t table_rows_log = std::ceil(std::log2(table_description_->rows_amount));
Expand Down
45 changes: 34 additions & 11 deletions bin/proof-generator/src/arg_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,39 @@ namespace nil {
GENERATE_READ_OPERATOR(CURVE_TYPES, CurvesVariant)
#undef X

#define HASH_TYPES \
X(nil::crypto3::hashes::keccak_1600<256>, "keccak") \
X(nil::crypto3::hashes::poseidon<nil::crypto3::hashes::detail::mina_poseidon_policy< \
typename nil::crypto3::algebra::curves::pallas::base_field_type>>, \
"poseidon")
#define X(type, name) TYPE_TO_STRING(type, name)
GENERATE_WRITE_OPERATOR(HASH_TYPES, HashesVariant)
#undef X
#define X(type, name) STRING_TO_TYPE(type, name)
GENERATE_READ_OPERATOR(HASH_TYPES, HashesVariant)
#undef X
std::ostream& operator<<(std::ostream& strm, const HashesVariant& variant) {
strm << std::visit(
[&strm](auto&& arg) -> std::string {
using SelectedType = std::decay_t<decltype(arg)>;
if constexpr (std::is_same_v<SelectedType, type_identity<nil::crypto3::hashes::keccak_1600<256>>>) return "keccak";
if constexpr (std::is_same_v<SelectedType, type_identity<nil::crypto3::hashes::sha2<256>>>) return "sha2";
if constexpr (std::is_same_v<SelectedType, type_identity<nil::crypto3::hashes::poseidon<nil::crypto3::hashes::detail::mina_poseidon_policy<nil::crypto3::algebra::curves::pallas::base_field_type>>>>) return "sha2";
strm.setstate(std::ios_base::failbit);
return "";
},
variant
);
return strm;
}

std::istream& operator>>(std::istream& strm, HashesVariant& variant) {
std::string str;
strm >> str;
if(str == "keccak") {
variant = std::variant_alternative_t<0, HashesVariant>();
return strm;
}
if(str == "sha2") {
variant = std::variant_alternative_t<1, HashesVariant>();
return strm;
}
if(str == "poseidon") {
variant = std::variant_alternative_t<2, HashesVariant>();
return strm;
}
strm.setstate(std::ios_base::failbit);
return strm;
}

} // namespace proof_generator
} // namespace nil
8 changes: 5 additions & 3 deletions bin/proof-generator/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ int grind_param_wrapper(const ProverOptions& prover_options) {
return ret;
}

template<typename CurveType, std::size_t LambdaParamIdx>
int hash_wrapper(const ProverOptions& prover_options) {
template<typename CurveType, std::size_t ColumnsParamsIdx, std::size_t LambdaParamIdx>
int hash_wrapper(const prover_options& prover_options) {
std::cout << "Hash wrapper" << std::endl;
int ret;
auto run_prover_wrapper_void = [&prover_options, &ret]<typename HashTypeIdentity>() {
using HashType = typename HashTypeIdentity::type;
Expand Down Expand Up @@ -104,7 +105,8 @@ int initial_wrapper(const ProverOptions& prover_options) {
}

int main(int argc, char* argv[]) {
std::optional<nil::proof_generator::ProverOptions> prover_options = nil::proof_generator::parse_args(argc, argv);
std::optional<nil::proof_generator::prover_options> prover_options = nil::proof_generator::parse_args(argc, argv);
std::cout << prover_options->circuit_file_path << std::endl;
if (!prover_options) {
// Action has already taken a place (help, version, etc.)
return 0;
Expand Down
2 changes: 1 addition & 1 deletion libs/actor/zk
Submodule zk updated 35 files
+3 −2 include/nil/crypto3/zk/commitments/batched_commitment.hpp
+25 −31 include/nil/crypto3/zk/commitments/detail/polynomial/basic_batched_fri_compile_time_size.hpp
+19 −23 include/nil/crypto3/zk/commitments/detail/polynomial/basic_batched_fri_runtime_size.hpp
+262 −118 include/nil/crypto3/zk/commitments/detail/polynomial/basic_fri.hpp
+17 −26 include/nil/crypto3/zk/commitments/detail/polynomial/proof_of_work.hpp
+4 −9 include/nil/crypto3/zk/commitments/polynomial/fri.hpp
+110 −48 include/nil/crypto3/zk/commitments/polynomial/kzg.hpp
+405 −0 include/nil/crypto3/zk/commitments/polynomial/kzg_v2.hpp
+69 −46 include/nil/crypto3/zk/commitments/polynomial/lpc.hpp
+30 −2 include/nil/crypto3/zk/commitments/type_traits.hpp
+111 −0 include/nil/crypto3/zk/detail/field_element_consumer.hpp
+5 −4 include/nil/crypto3/zk/snark/arithmetization/plonk/constraint.hpp
+21 −10 include/nil/crypto3/zk/snark/arithmetization/plonk/constraint_system.hpp
+37 −1 include/nil/crypto3/zk/snark/arithmetization/plonk/copy_constraint.hpp
+16 −0 include/nil/crypto3/zk/snark/arithmetization/plonk/table_description.hpp
+4 −0 include/nil/crypto3/zk/snark/arithmetization/plonk/variable.hpp
+65 −4 include/nil/crypto3/zk/snark/systems/plonk/placeholder/detail/profiling.hpp
+9 −1 include/nil/crypto3/zk/snark/systems/plonk/placeholder/detail/transcript_initialization_context.hpp
+233 −41 include/nil/crypto3/zk/snark/systems/plonk/placeholder/lookup_argument.hpp
+165 −45 include/nil/crypto3/zk/snark/systems/plonk/placeholder/permutation_argument.hpp
+114 −62 include/nil/crypto3/zk/snark/systems/plonk/placeholder/preprocessor.hpp
+3 −1 include/nil/crypto3/zk/snark/systems/plonk/placeholder/proof.hpp
+23 −15 include/nil/crypto3/zk/snark/systems/plonk/placeholder/prover.hpp
+110 −69 include/nil/crypto3/zk/snark/systems/plonk/placeholder/verifier.hpp
+41 −23 include/nil/crypto3/zk/transcript/fiat_shamir.hpp
+5 −2 test/commitment/fri.cpp
+514 −4 test/commitment/kzg.cpp
+26 −16 test/commitment/lpc.cpp
+12 −9 test/commitment/lpc_performance.cpp
+10 −11 test/commitment/proof_of_work.cpp
+99 −34 test/systems/plonk/placeholder/circuits.hpp
+7 −20 test/systems/plonk/placeholder/performance.cpp
+467 −100 test/systems/plonk/placeholder/placeholder.cpp
+35 −3 test/systems/plonk/plonk_constraint.cpp
+14 −1 test/transcript/transcript.cpp

0 comments on commit 0052ec3

Please sign in to comment.