diff --git a/crypto3/libs/marshalling/algebra/include/nil/crypto3/marshalling/algebra/types/curve_element.hpp b/crypto3/libs/marshalling/algebra/include/nil/crypto3/marshalling/algebra/types/curve_element.hpp index 2a1a3e21d1..03ff1e6958 100644 --- a/crypto3/libs/marshalling/algebra/include/nil/crypto3/marshalling/algebra/types/curve_element.hpp +++ b/crypto3/libs/marshalling/algebra/include/nil/crypto3/marshalling/algebra/types/curve_element.hpp @@ -2,6 +2,7 @@ // Copyright (c) 2017-2021 Mikhail Komarov // Copyright (c) 2020-2021 Nikita Kaskov // Copyright (c) 2021 Ilias Khairullin +// Copyright (c) 2024 Vasiliy Olekhov // // MIT License // @@ -355,12 +356,13 @@ namespace nil { return field; } + template + using curve_element_vector = nil::marshalling::types::standard_array_list< + TTypeBase, + curve_element>; + template - nil::marshalling::types::array_list< - nil::marshalling::field_type, - curve_element, CurveGroupType>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral, std::size_t>>> + curve_element_vector> fill_curve_element_vector( const std::vector &curve_elem_vector) { @@ -368,14 +370,7 @@ namespace nil { using curve_element_type = curve_element; - using curve_element_vector_type = nil::marshalling::types::array_list< - TTypeBase, - curve_element_type, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral, std::size_t>>>; - - curve_element_vector_type result; - + curve_element_vector result; std::vector &val = result.value(); for (std::size_t i = 0; i < curve_elem_vector.size(); i++) { val.push_back(curve_element_type(curve_elem_vector[i])); @@ -385,11 +380,7 @@ namespace nil { template std::vector make_curve_element_vector( - const nil::marshalling::types::array_list< - nil::marshalling::field_type, - curve_element, CurveGroupType>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral, std::size_t>>> + const curve_element_vector> &curve_elem_vector) { std::vector result; diff --git a/crypto3/libs/marshalling/algebra/include/nil/crypto3/marshalling/algebra/types/field_element.hpp b/crypto3/libs/marshalling/algebra/include/nil/crypto3/marshalling/algebra/types/field_element.hpp index 8efabeb6a9..e253e1d8d0 100644 --- a/crypto3/libs/marshalling/algebra/include/nil/crypto3/marshalling/algebra/types/field_element.hpp +++ b/crypto3/libs/marshalling/algebra/include/nil/crypto3/marshalling/algebra/types/field_element.hpp @@ -2,6 +2,7 @@ // Copyright (c) 2017-2021 Mikhail Komarov // Copyright (c) 2020-2021 Nikita Kaskov // Copyright (c) 2021 Ilias Khairullin +// Copyright (c) 2024 Vasiliy Olekhov // // MIT License // @@ -686,13 +687,11 @@ namespace nil { // return field; // } - + template - using field_element_vector = nil::marshalling::types::array_list< + using field_element_vector = nil::marshalling::types::standard_array_list< TTypeBase, - field_element, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>; + field_element>; template field_element_vector> @@ -700,13 +699,8 @@ namespace nil { using TTypeBase = nil::marshalling::field_type; using field_element_type = field_element; - using field_element_vector_type = nil::marshalling::types::array_list< - TTypeBase, - field_element_type, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>; - field_element_vector_type result; + field_element_vector result; for (std::size_t i = 0; i < field_elem_vector.size(); i++) { result.value().push_back(field_element_type(field_elem_vector[i])); } diff --git a/crypto3/libs/marshalling/algebra/test/field_element.cpp b/crypto3/libs/marshalling/algebra/test/field_element.cpp index 1a11c1a261..0aa93631c1 100644 --- a/crypto3/libs/marshalling/algebra/test/field_element.cpp +++ b/crypto3/libs/marshalling/algebra/test/field_element.cpp @@ -45,13 +45,6 @@ #include #include -template -void print_byteblob(TIter iter_begin, TIter iter_end) { - for (TIter it = iter_begin; it != iter_end; it++) { - std::cout << std::hex << int(*it) << std::endl; - } -} - template void test_field_element(T val) { @@ -80,47 +73,63 @@ void test_field_element(T val) { BOOST_CHECK(status == nil::marshalling::status_type::success); } +template +void test_field_element_vector() { + + using namespace nil::crypto3::marshalling; + + using unit_type = unsigned char; + using field_element_type = types::field_element, + T>; + + std::vector vec(16); + + for(auto &v : vec) { + v = nil::crypto3::algebra::random_element(); + } + + nil::marshalling::status_type status; + std::vector cv = nil::marshalling::pack(vec, status); + + BOOST_CHECK(status == nil::marshalling::status_type::success); + + std::vector test_val = nil::marshalling::pack(cv, status); + + BOOST_CHECK(vec == test_val); + BOOST_CHECK(status == nil::marshalling::status_type::success); +} + + template void test_field_element() { - std::cout << std::hex; - std::cerr << std::hex; for (unsigned i = 0; i < 128; ++i) { - if (!(i % 16) && i) { - std::cout << std::dec << i << " tested" << std::endl; - } typename FieldType::value_type val = nil::crypto3::algebra::random_element(); test_field_element(val); } + + test_field_element_vector(); } BOOST_AUTO_TEST_SUITE(field_element_test_suite) BOOST_AUTO_TEST_CASE(field_element_bls12_381_g1_field_be) { - std::cout << "BLS12-381 g1 group field big-endian test started" << std::endl; test_field_element::g1_type<>::field_type, nil::marshalling::option::big_endian>(); - std::cout << "BLS12-381 g1 group field big-endian test finished" << std::endl; } BOOST_AUTO_TEST_CASE(field_element_bls12_381_g1_field_le) { - std::cout << "BLS12-381 g1 group field little-endian test started" << std::endl; test_field_element::g1_type<>::field_type, nil::marshalling::option::little_endian>(); - std::cout << "BLS12-381 g1 group field little-endian test finished" << std::endl; } BOOST_AUTO_TEST_CASE(field_element_bls12_381_g2_field_be) { - std::cout << "BLS12-381 g2 group field big-endian test started" << std::endl; test_field_element::g2_type<>::field_type, nil::marshalling::option::big_endian>(); - std::cout << "BLS12-381 g2 group field big-endian test finished" << std::endl; } BOOST_AUTO_TEST_CASE(field_element_bls12_381_g2_field_le) { - std::cout << "BLS12-381 g2 group field little-endian test started" << std::endl; test_field_element::g2_type<>::field_type, nil::marshalling::option::little_endian>(); - std::cout << "BLS12-381 g2 group field little-endian test finished" << std::endl; } BOOST_AUTO_TEST_SUITE_END() diff --git a/crypto3/libs/marshalling/containers/include/nil/crypto3/marshalling/containers/types/merkle_node.hpp b/crypto3/libs/marshalling/containers/include/nil/crypto3/marshalling/containers/types/merkle_node.hpp index 77ad27e04d..7a6a727888 100644 --- a/crypto3/libs/marshalling/containers/include/nil/crypto3/marshalling/containers/types/merkle_node.hpp +++ b/crypto3/libs/marshalling/containers/include/nil/crypto3/marshalling/containers/types/merkle_node.hpp @@ -59,11 +59,8 @@ namespace nil { typename std::enable_if::value_type>::value>::type> { - using type = nil::marshalling::types::array_list< - TTypeBase, - nil::marshalling::types::integral, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>; + using type = nil::marshalling::types::standard_array_list< + TTypeBase, nil::marshalling::types::integral>; }; // For Poseidon, Merkle node will contain a Group Element, not a vector of bytes. diff --git a/crypto3/libs/marshalling/containers/include/nil/crypto3/marshalling/containers/types/merkle_proof.hpp b/crypto3/libs/marshalling/containers/include/nil/crypto3/marshalling/containers/types/merkle_proof.hpp index 60f5bc2b70..b5af6953b5 100644 --- a/crypto3/libs/marshalling/containers/include/nil/crypto3/marshalling/containers/types/merkle_proof.hpp +++ b/crypto3/libs/marshalling/containers/include/nil/crypto3/marshalling/containers/types/merkle_proof.hpp @@ -63,23 +63,18 @@ namespace nil { template struct merkle_proof_layer { - using type = nil::marshalling::types::array_list< + using type = nil::marshalling::types::standard_array_list< TTypeBase, // path_element_t - typename merkle_proof_path_element::type, - // layer - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>; + typename merkle_proof_path_element::type>; }; template struct merkle_proof_path { - using type = nil::marshalling::types::array_list< + using type = nil::marshalling::types::standard_array_list< TTypeBase, // layer path - typename merkle_proof_layer::type, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>; + typename merkle_proof_layer::type>; }; template - using merkle_tree = nil::marshalling::types::array_list< + using merkle_tree = nil::marshalling::types::standard_array_list< TTypeBase, - typename merkle_node_value::type, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>; + typename merkle_node_value::type>; template merkle_tree, MerkleTree> diff --git a/crypto3/libs/marshalling/math/include/nil/crypto3/marshalling/math/types/expression.hpp b/crypto3/libs/marshalling/math/include/nil/crypto3/marshalling/math/types/expression.hpp index 080026cda8..40834c05c4 100644 --- a/crypto3/libs/marshalling/math/include/nil/crypto3/marshalling/math/types/expression.hpp +++ b/crypto3/libs/marshalling/math/include/nil/crypto3/marshalling/math/types/expression.hpp @@ -91,25 +91,19 @@ namespace nil { TTypeBase, std::tuple< // std::vector> terms - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - typename term::type, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral> + typename term::type >, // std::vector pow_operations - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - typename flat_pow_operation::type, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral> + typename flat_pow_operation::type >, // std::vector binary_operations - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - typename flat_binary_arithmetic_operation::type, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral> + typename flat_binary_arithmetic_operation::type >, // flat_node_type root_type; nil::marshalling::types::integral, @@ -152,37 +146,26 @@ namespace nil { const auto& flat_expr = flattener.get_result(); using TTypeBase = nil::marshalling::field_type; - using size_t_marshalling_type = nil::marshalling::types::integral; // Fill the terms. - using term_marshalling_type = - typename term::type; - using term_vector_marshalling_type = nil::marshalling::types::array_list< - TTypeBase, term_marshalling_type, - nil::marshalling::option::sequence_size_field_prefix>; - term_vector_marshalling_type filled_terms; + nil::marshalling::types::standard_array_list::type> filled_terms; for (const auto &term : flat_expr.terms) { filled_terms.value().push_back( fill_term(term)); } // Fill the power operations. - using pow_operation_type = typename flat_pow_operation::type; - using pow_vector_marshalling_type = nil::marshalling::types::array_list< - TTypeBase, pow_operation_type, nil::marshalling::option::sequence_size_field_prefix< - size_t_marshalling_type>>; - pow_vector_marshalling_type filled_powers; + nil::marshalling::types::standard_array_list::type> filled_powers; for (const auto &power : flat_expr.pow_operations) { filled_powers.value().push_back(fill_power_operation(power)); } // Fill the binary operations. - using binary_operation_type = typename flat_binary_arithmetic_operation::type; - using binary_operation_vector_marshalling_type = nil::marshalling::types::array_list< - TTypeBase, binary_operation_type, - nil::marshalling::option::sequence_size_field_prefix>; - binary_operation_vector_marshalling_type filled_binary_opeations; + nil::marshalling::types::standard_array_list::type> filled_binary_operations; for (const auto &bin_op : flat_expr.binary_operations) { - filled_binary_opeations.value().push_back( + filled_binary_operations.value().push_back( fill_binary_operation(bin_op)); } @@ -190,7 +173,7 @@ namespace nil { std::make_tuple( filled_terms, filled_powers, - filled_binary_opeations, + filled_binary_operations, nil::marshalling::types::integral((std::uint8_t)flat_expr.root_type), nil::marshalling::types::integral(flat_expr.root_index))); diff --git a/crypto3/libs/marshalling/math/include/nil/crypto3/marshalling/math/types/term.hpp b/crypto3/libs/marshalling/math/include/nil/crypto3/marshalling/math/types/term.hpp index 6dfa6d3a78..fbbf0592b4 100644 --- a/crypto3/libs/marshalling/math/include/nil/crypto3/marshalling/math/types/term.hpp +++ b/crypto3/libs/marshalling/math/include/nil/crypto3/marshalling/math/types/term.hpp @@ -53,11 +53,8 @@ namespace nil { // assignment_type coeff field_element, // std::vector vars - nil::marshalling::types::array_list< - TTypeBase, typename variable::type, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral> - > + nil::marshalling::types::standard_array_list< + TTypeBase, typename variable::type> > >; }; @@ -68,14 +65,12 @@ namespace nil { using TTypeBase = nil::marshalling::field_type; using result_type = typename term::type; - using size_t_marshalling_type = nil::marshalling::types::integral; using field_element_marhsalling_type = field_element; using variable_marshalling_type = typename variable::type; - using variable_vector_marshalling_type = nil::marshalling::types::array_list< - TTypeBase, variable_marshalling_type, - nil::marshalling::option::sequence_size_field_prefix>; + using variable_vector_marshalling_type = nil::marshalling::types::standard_array_list< + TTypeBase, variable_marshalling_type>; variable_vector_marshalling_type filled_vars; for (const auto &var : t.get_vars()) { diff --git a/crypto3/libs/marshalling/multiprecision/include/nil/crypto3/marshalling/multiprecision/types/integral.hpp b/crypto3/libs/marshalling/multiprecision/include/nil/crypto3/marshalling/multiprecision/types/integral.hpp index 93eabb2606..7654b9c828 100644 --- a/crypto3/libs/marshalling/multiprecision/include/nil/crypto3/marshalling/multiprecision/types/integral.hpp +++ b/crypto3/libs/marshalling/multiprecision/include/nil/crypto3/marshalling/multiprecision/types/integral.hpp @@ -400,22 +400,18 @@ namespace nil { } template - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< nil::marshalling::field_type, - integral, IntegralContainer>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral, std::size_t>>> + integral, IntegralContainer>> fill_integral_vector(std::vector integral_vector) { using TTypeBase = nil::marshalling::field_type; using integral_type = integral; - using integral_vector_type = nil::marshalling::types::array_list< + using integral_vector_type = nil::marshalling::types::standard_array_list< TTypeBase, - integral_type, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral, std::size_t>>>; + integral_type>; integral_vector_type result; @@ -428,11 +424,9 @@ namespace nil { template std::vector make_integral_vector( - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< nil::marshalling::field_type, - integral, IntegralContainer>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral, std::size_t>>> + integral, IntegralContainer>> integral_vector) { std::vector result; diff --git a/crypto3/libs/marshalling/multiprecision/test/integral_fixed_size_container.cpp b/crypto3/libs/marshalling/multiprecision/test/integral_fixed_size_container.cpp index 9da11155c3..b0037f50bf 100644 --- a/crypto3/libs/marshalling/multiprecision/test/integral_fixed_size_container.cpp +++ b/crypto3/libs/marshalling/multiprecision/test/integral_fixed_size_container.cpp @@ -83,9 +83,9 @@ void test_round_trip_fixed_size_container_fixed_precision_big_endian( using unit_type = OutputType; using integral_type = types::integral, T>; - using container_type = - nil::marshalling::types::array_list, - integral_type, nil::marshalling::option::fixed_size_storage>; + using container_type = nil::marshalling::types::standard_array_list< + nil::marshalling::field_type, + integral_type>; std::size_t unitblob_size = integral_type::bit_length() / units_bits + ((integral_type::bit_length() % units_bits) ? 1 : 0); @@ -125,9 +125,9 @@ void test_round_trip_fixed_size_container_fixed_precision_little_endian( using unit_type = OutputType; using integral_type = types::integral, T>; - using container_type = - nil::marshalling::types::array_list, - integral_type, nil::marshalling::option::fixed_size_storage>; + using container_type = nil::marshalling::types::standard_array_list< + nil::marshalling::field_type, + integral_type>; std::size_t unitblob_size = integral_type::bit_length() / units_bits + ((integral_type::bit_length() % units_bits) ? 1 : 0); diff --git a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/commitment_params.hpp b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/commitment_params.hpp index d83108b5b2..085a76208d 100644 --- a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/commitment_params.hpp +++ b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/commitment_params.hpp @@ -1,5 +1,6 @@ //---------------------------------------------------------------------------// // Copyright (c) 2023 Martun Karapetyan +// Copyright (c) 2024 Vasiliy Olekhov // // MIT License // @@ -45,31 +46,20 @@ namespace nil { namespace marshalling { namespace types { template - using field_element_vector_type = nil::marshalling::types::array_list< + using field_element_vector_type = nil::marshalling::types::standard_array_list< TTypeBase, - field_element, - nil::marshalling::option::sequence_size_field_prefix> + field_element >; // ******************* Marshalling of commitment params for Basic Fri and KZG. ********************************* // template - nil::marshalling::types::array_list< - nil::marshalling::field_type, - nil::marshalling::types::integral, IntegerType>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral, std::size_t>> - > - fill_integer_vector(const std::vector& integral_vector) { + nil::marshalling::types::standard_size_t_array_list> + fill_integer_vector(const std::vector& integral_vector) { using TTypeBase = nil::marshalling::field_type; using integral_type = nil::marshalling::types::integral; - using integral_vector_type = nil::marshalling::types::array_list< - TTypeBase, - integral_type, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral> - >; + using integral_vector_type = nil::marshalling::types::standard_size_t_array_list; integral_vector_type result; @@ -82,11 +72,8 @@ namespace nil { template std::vector - make_integer_vector(const nil::marshalling::types::array_list< - nil::marshalling::field_type, - nil::marshalling::types::integral, IntegerType>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral, std::size_t>> + make_integer_vector(const nil::marshalling::types::standard_size_t_array_list< + nil::marshalling::field_type >& filled_vector) { std::vector result; for( std::size_t i = 0; i < filled_vector.value().size(); i++){ @@ -126,7 +113,11 @@ namespace nil { // Define commitment_params marshalling type for LPC. template - struct commitment_params>> { + struct commitment_params< + TTypeBase, + CommitmentSchemeType, + std::enable_if_t> + > { using CommitmentParamsType = typename CommitmentSchemeType::params_type; using integral_type = nil::marshalling::types::integral; using type = @@ -145,12 +136,7 @@ namespace nil { // For each evaluation_domain we will include the unity root only. field_element_vector_type, // const std::vector step_list; - nil::marshalling::types::array_list< - TTypeBase, - integral_type, - nil::marshalling::option::sequence_size_field_prefix< - integral_type> - >, + nil::marshalling::types::standard_size_t_array_list, // const std::size_t expand_factor; integral_type > @@ -159,8 +145,11 @@ namespace nil { // Marshalling function for FRI params. template - typename commitment_params, CommitmentSchemeType, std::enable_if_t>>::type - fill_commitment_params(const typename CommitmentSchemeType::params_type &fri_params) { + typename commitment_params< + nil::marshalling::field_type, + CommitmentSchemeType, + std::enable_if_t> + >::type fill_commitment_params(const typename CommitmentSchemeType::params_type &fri_params) { using CommitmentParamsType = typename CommitmentSchemeType::params_type; using TTypeBase = typename nil::marshalling::field_type; using FieldType = typename CommitmentParamsType::field_type; @@ -176,8 +165,7 @@ namespace nil { nil::marshalling::types::integral(fri_params.m), nil::marshalling::types::integral(fri_params.use_grinding?fri_params.grinding_parameter:0), nil::marshalling::types::integral(fri_params.max_degree), - nil::crypto3::marshalling::types::fill_field_element_vector< - typename FieldType::value_type, Endianness>(D_unity_roots), + fill_field_element_vector(D_unity_roots), fill_integer_vector(fri_params.step_list), nil::marshalling::types::integral(fri_params.expand_factor) )); @@ -223,18 +211,15 @@ namespace nil { TTypeBase, std::tuple< // std::vector::value_type> commitment_key; - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< nil::marshalling::field_type, - curve_element, typename CommitmentSchemeType::curve_type::template g1_type<>>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral, std::size_t>>> + curve_element, typename CommitmentSchemeType::curve_type::template g1_type<>> +> , // verification_key_type verification_key; - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< nil::marshalling::field_type, - curve_element, typename CommitmentSchemeType::curve_type::template g2_type<>>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral, std::size_t>>> + curve_element, typename CommitmentSchemeType::curve_type::template g2_type<>>> > >; }; @@ -245,18 +230,14 @@ namespace nil { fill_commitment_params(const typename CommitmentSchemeType::params_type &kzg_params) { using result_type = typename commitment_params, CommitmentSchemeType>::type; - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< nil::marshalling::field_type, - curve_element, typename CommitmentSchemeType::curve_type::template g1_type<>>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral, std::size_t>>> + curve_element, typename CommitmentSchemeType::curve_type::template g1_type<>>> filled_commitment = fill_curve_element_vector, Endianness>(kzg_params.commitment_key); - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< nil::marshalling::field_type, - curve_element, typename CommitmentSchemeType::curve_type::template g2_type<>>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral, std::size_t>>> + curve_element, typename CommitmentSchemeType::curve_type::template g2_type<>>> filled_verification_key = fill_curve_element_vector, Endianness>(kzg_params.verification_key); return result_type(std::make_tuple( diff --git a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/eval_storage.hpp b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/eval_storage.hpp index 5b446cb540..b84b3a2a6e 100644 --- a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/eval_storage.hpp +++ b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/eval_storage.hpp @@ -65,23 +65,20 @@ namespace nil { // batch_info. // We'll check is it good for current EVM instance // All z-s are placed into plain array - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - field_element, - nil::marshalling::option::sequence_size_field_prefix> + field_element >, - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - nil::marshalling::types::integral, - nil::marshalling::option::sequence_size_field_prefix> + nil::marshalling::types::integral >, // evaluation_points_num. - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - nil::marshalling::types::integral, - nil::marshalling::option::sequence_size_field_prefix> + nil::marshalling::types::integral > > >; @@ -93,10 +90,9 @@ namespace nil { nil::crypto3::marshalling::types::batch_info_type batch_info; - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - nil::marshalling::types::integral, - nil::marshalling::option::sequence_size_field_prefix> + nil::marshalling::types::integral > filled_batch_info; auto batches = z.get_batches(); for( std::size_t i = 0; i < batches.size(); i++ ){ @@ -105,10 +101,9 @@ namespace nil { filled_batch_info.value().push_back(nil::marshalling::types::integral(z.get_batch_size(batches[i]))); } - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - nil::marshalling::types::integral, - nil::marshalling::option::sequence_size_field_prefix> + nil::marshalling::types::integral > filled_eval_points_num; for( std::size_t i = 0; i < batches.size(); i++ ){ for( std::size_t j = 0; j < z.get_batch_size(batches[i]); j++ ){ @@ -126,10 +121,9 @@ namespace nil { } } } - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - field_element, - nil::marshalling::option::sequence_size_field_prefix> + field_element > filled_z = fill_field_element_vector(z_val); return eval_storage( diff --git a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/fri.hpp b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/fri.hpp index 86efdb6416..59872536a1 100644 --- a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/fri.hpp +++ b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/fri.hpp @@ -55,10 +55,9 @@ namespace nil { // fri::merkle_proofs marshalling /////////////////////////////////////////////////// template - using merkle_proof_vector_type = nil::marshalling::types::array_list< + using merkle_proof_vector_type = nil::marshalling::types::standard_array_list< TTypeBase, - types::merkle_proof, - nil::marshalling::option::sequence_size_field_prefix> + types::merkle_proof >; template< typename Endianness, typename FRI > @@ -188,10 +187,9 @@ namespace nil { TTypeBase, std::tuple< // std::vector> y; - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - field_element, - nil::marshalling::option::size_t_sequence_size_field_prefix + field_element >, // merkle_proof_type p; typename types::merkle_proof @@ -256,16 +254,14 @@ namespace nil { TTypeBase, std::tuple< // std::map initial_proof; - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - fri_initial_proof_type, - nil::marshalling::option::size_t_sequence_size_field_prefix + fri_initial_proof_type >, // std::vector round_proofs; - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - fri_round_proof_type, - nil::marshalling::option::size_t_sequence_size_field_prefix + fri_round_proof_type > > >; @@ -335,51 +331,46 @@ namespace nil { std::tuple< // step_list.size() merkle roots // Fixed size. It's Ok - nil::marshalling::types::array_list< - TTypeBase, typename types::merkle_node_value::type, - nil::marshalling::option::sequence_size_field_prefix> + nil::marshalling::types::standard_array_list< + TTypeBase, + typename types::merkle_node_value::type >, // step_list. // We'll check is it good for current EVM instance - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - nil::marshalling::types::integral, - nil::marshalling::option::sequence_size_field_prefix> + nil::marshalling::types::integral >, // Polynomials' values for initial proofs // Fixed size // lambda * polynomials_num * m - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - field_element, - nil::marshalling::option::sequence_size_field_prefix> + field_element >, // Polynomials' values for round proofs // Fixed size // lambda * \sum_rounds{m^{r_i}} - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - field_element, - nil::marshalling::option::sequence_size_field_prefix> + field_element >, // Merkle proofs for initial proofs // Fixed size lambda * batches_num - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - typename types::merkle_proof, - nil::marshalling::option::sequence_size_field_prefix> + typename types::merkle_proof >, // Merkle proofs for round proofs // Fixed size lambda * |step_list| - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - typename types::merkle_proof, - nil::marshalling::option::sequence_size_field_prefix> + typename types::merkle_proof >, // std::select_container final_polynomials @@ -400,9 +391,8 @@ namespace nil { using TTypeBase = nil::marshalling::field_type; // merkle roots - nil::marshalling::types::array_list< - TTypeBase, typename types::merkle_node_value::type, - nil::marshalling::option::sequence_size_field_prefix> + nil::marshalling::types::standard_array_list< + TTypeBase, typename types::merkle_node_value::type > filled_fri_roots; for( size_t i = 0; i < proof.fri_roots.size(); i++){ filled_fri_roots.value().push_back(fill_merkle_node_value(proof.fri_roots[i])); @@ -426,10 +416,9 @@ namespace nil { } } } - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - field_element, - nil::marshalling::option::sequence_size_field_prefix> + field_element > filled_initial_val = fill_field_element_vector(initial_val); // fill round values @@ -444,27 +433,24 @@ namespace nil { } } } - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - field_element, - nil::marshalling::option::sequence_size_field_prefix> + field_element > filled_round_val = fill_field_element_vector(round_val); // step_list - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - nil::marshalling::types::integral, - nil::marshalling::option::sequence_size_field_prefix> + nil::marshalling::types::integral > filled_step_list; for (const auto& step : params.step_list) { filled_step_list.value().push_back(nil::marshalling::types::integral(step)); } // initial merkle proofs - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - typename types::merkle_proof, - nil::marshalling::option::sequence_size_field_prefix> + typename types::merkle_proof > filled_initial_merkle_proofs; for( std::size_t i = 0; i < lambda; i++){ const auto &query_proof = proof.query_proofs[i]; @@ -477,10 +463,9 @@ namespace nil { } // round merkle proofs - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - typename types::merkle_proof, - nil::marshalling::option::sequence_size_field_prefix> + typename types::merkle_proof > filled_round_merkle_proofs; for( std::size_t i = 0; i < lambda; i++){ const auto &query_proof = proof.query_proofs[i]; diff --git a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/lpc.hpp b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/lpc.hpp index 74c4574242..4b5db63b8b 100644 --- a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/lpc.hpp +++ b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/lpc.hpp @@ -92,20 +92,11 @@ namespace nil { using type = nil::marshalling::types::bundle< TTypeBase, std::tuple< - nil::marshalling::types::array_list< + nil::marshalling::types::standard_size_t_array_list, + nil::marshalling::types::standard_size_t_array_list, + nil::marshalling::types::standard_array_list< TTypeBase, - nil::marshalling::types::integral, - nil::marshalling::option::sequence_size_field_prefix> - >, - nil::marshalling::types::array_list< - TTypeBase, - nil::marshalling::types::integral, - nil::marshalling::option::sequence_size_field_prefix> - >, - nil::marshalling::types::array_list< - TTypeBase, - field_element, - nil::marshalling::option::sequence_size_field_prefix> + field_element > > >; @@ -123,20 +114,11 @@ namespace nil { using result_type = typename commitment_preprocessed_data< nil::marshalling::field_type, LPCScheme >::type; - nil::marshalling::types::array_list< - TTypeBase, - nil::marshalling::types::integral, - nil::marshalling::option::sequence_size_field_prefix> - > filled_map_ids; - nil::marshalling::types::array_list< - TTypeBase, - nil::marshalling::types::integral, - nil::marshalling::option::sequence_size_field_prefix> - > filled_sizes; - nil::marshalling::types::array_list< + nil::marshalling::types::standard_size_t_array_list filled_map_ids; + nil::marshalling::types::standard_size_t_array_list filled_sizes; + nil::marshalling::types::standard_array_list< TTypeBase, - field_element, - nil::marshalling::option::sequence_size_field_prefix> + field_element > filled_values; for (const auto&[k, v]: lpc_data) { @@ -163,8 +145,6 @@ namespace nil { std::enable_if_t> >::type const& filled_commitment_preprocessed_data ) { - using TTypeBase = nil::marshalling::field_type; - typename LPCScheme::preprocessed_data_type result; for(std::size_t i = 0; i < std::get<0>(filled_commitment_preprocessed_data.value()).value().size(); i++){ std::size_t k = std::get<0>(filled_commitment_preprocessed_data.value()).value()[i].value(); @@ -264,17 +244,10 @@ namespace nil { TTypeBase, std::tuple< // std::map _trees; - nil::marshalling::types::array_list< + nil::marshalling::types::standard_size_t_array_list< TTypeBase >, + nil::marshalling::types::standard_array_list< TTypeBase, - nil::marshalling::types::integral, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral> - >, - nil::marshalling::types::array_list< - TTypeBase, - typename precommitment_type::type, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral> + typename precommitment_type::type >, // typename fri_type::params_type _fri_params; typename commitment_params::type, @@ -283,20 +256,10 @@ namespace nil { field_element, //std::map _batch_fixed; - nil::marshalling::types::array_list< - TTypeBase, - nil::marshalling::types::integral, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral> - >, + nil::marshalling::types::standard_size_t_array_list, // Next value was supposed to be a vector of bool, but our marshalling core // does not allow us to create an array_list of bools. - nil::marshalling::types::array_list< - TTypeBase, - nil::marshalling::types::integral, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral> - >, + nil::marshalling::types::standard_size_t_array_list, // preprocessed_data_type _fixed_polys_values; typename commitment_preprocessed_data< TTypeBase, LPCScheme, @@ -316,18 +279,10 @@ namespace nil { using result_type = typename commitment_scheme_state, LPCScheme>::type; // std::map _trees; - nil::marshalling::types::array_list< - TTypeBase, - nil::marshalling::types::integral, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral> - > filled_trees_keys; - nil::marshalling::types::array_list< + nil::marshalling::types::standard_size_t_array_list filled_trees_keys; + nil::marshalling::types::standard_array_list< TTypeBase, - typename precommitment_type::type, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral> - > filled_trees_values; + typename precommitment_type::type> filled_trees_values; for (const auto&[key, value]: scheme.get_trees()) { filled_trees_keys.value().push_back(nil::marshalling::types::integral(key)); // Precommitment for LPC is a merkle tree. We may want to abstract away this part into a separate @@ -337,18 +292,8 @@ namespace nil { } //std::map _batch_fixed; - nil::marshalling::types::array_list< - TTypeBase, - nil::marshalling::types::integral, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral> - > filled_batch_fixed_keys; - nil::marshalling::types::array_list< - TTypeBase, - nil::marshalling::types::integral, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral> - > filled_batch_fixed_values; + nil::marshalling::types::standard_size_t_array_list filled_batch_fixed_keys; + nil::marshalling::types::standard_size_t_array_list filled_batch_fixed_values; for (const auto&[key, value]: scheme.get_batch_fixed()) { filled_batch_fixed_keys.value().push_back( nil::marshalling::types::integral(key)); @@ -377,8 +322,6 @@ namespace nil { nil::marshalling::field_type, LPCScheme, std::enable_if_t>>::type& filled_commitment_scheme ) { - using TTypeBase = typename nil::marshalling::field_type; - std::map trees; const auto& filled_tree_keys = std::get<0>(filled_commitment_scheme.value()).value(); const auto& filled_tree_values = std::get<1>(filled_commitment_scheme.value()).value(); @@ -494,8 +437,6 @@ namespace nil { fill_initial_eval_proof( const typename LPCScheme::lpc_proof_type &intial_proof ){ - using TTypeBase = nil::marshalling::field_type; - auto filled_z = fill_eval_storage( intial_proof.z); diff --git a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/powers_of_tau/accumulator.hpp b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/powers_of_tau/accumulator.hpp index c832d96645..0390bc8347 100644 --- a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/powers_of_tau/accumulator.hpp +++ b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/powers_of_tau/accumulator.hpp @@ -67,29 +67,21 @@ namespace nil { TTypeBase, std::tuple< // tau_powers_g1 - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - fast_curve_element>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>, + fast_curve_element>>, // tau_powers_g2 - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - fast_curve_element>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>, + fast_curve_element>>, // alpha_tau_powers_g1 - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - fast_curve_element>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>, + fast_curve_element>>, // beta_tau_powers_g1 - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - fast_curve_element>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>, + fast_curve_element>>, // beta_g2 fast_curve_element> >>; diff --git a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/powers_of_tau/result.hpp b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/powers_of_tau/result.hpp index 71bdb54eae..eaaf14b4da 100644 --- a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/powers_of_tau/result.hpp +++ b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/commitments/powers_of_tau/result.hpp @@ -72,35 +72,25 @@ namespace nil { // beta_g2 fast_curve_element>, // coeffs_g1 - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - fast_curve_element>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>, + fast_curve_element>>, // coeffs_g2 - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - fast_curve_element>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>, + fast_curve_element>>, // alpha_coeffs_g1 - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - fast_curve_element>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>, + fast_curve_element>>, // beta_coeffs_g1 - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - fast_curve_element>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>, + fast_curve_element>>, // h - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - fast_curve_element>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>> + fast_curve_element>> >>; template diff --git a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/fast_knowledge_commitment.hpp b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/fast_knowledge_commitment.hpp index 9a3ebfe772..78b44857c4 100644 --- a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/fast_knowledge_commitment.hpp +++ b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/fast_knowledge_commitment.hpp @@ -88,11 +88,9 @@ namespace nil { } template - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< nil::marshalling::field_type, - fast_knowledge_commitment, KnowledgeCommitment>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral, std::size_t>>> + fast_knowledge_commitment, KnowledgeCommitment>> fill_fast_knowledge_commitment_vector( const std::vector &kc_vector) { @@ -100,11 +98,9 @@ namespace nil { using kc_element_type = fast_knowledge_commitment; - using kc_element_vector_type = nil::marshalling::types::array_list< + using kc_element_vector_type = nil::marshalling::types::standard_array_list< TTypeBase, - kc_element_type, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral, std::size_t>>>; + kc_element_type>; kc_element_vector_type result; @@ -117,11 +113,9 @@ namespace nil { template std::vector make_fast_knowledge_commitment_vector( - const nil::marshalling::types::array_list< + const nil::marshalling::types::standard_array_list< nil::marshalling::field_type, - fast_knowledge_commitment, KnowledgeCommitment>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral, std::size_t>>> + fast_knowledge_commitment, KnowledgeCommitment>> &filled_kc_vector) { std::vector result; diff --git a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/knowledge_commitment.hpp b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/knowledge_commitment.hpp index 25dc57b4af..f4c52c85b0 100644 --- a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/knowledge_commitment.hpp +++ b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/knowledge_commitment.hpp @@ -91,11 +91,9 @@ namespace nil { } template - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< nil::marshalling::field_type, - knowledge_commitment, KnowledgeCommitment>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral, std::size_t>>> + knowledge_commitment, KnowledgeCommitment>> fill_knowledge_commitment_vector( const std::vector &kc_vector) { @@ -103,11 +101,9 @@ namespace nil { using kc_element_type = knowledge_commitment; - using kc_element_vector_type = nil::marshalling::types::array_list< + using kc_element_vector_type = nil::marshalling::types::standard_array_list< TTypeBase, - kc_element_type, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral, std::size_t>>>; + kc_element_type>; kc_element_vector_type result; @@ -120,11 +116,9 @@ namespace nil { template std::vector make_knowledge_commitment_vector( - const nil::marshalling::types::array_list< + const nil::marshalling::types::standard_array_list< nil::marshalling::field_type, - knowledge_commitment, KnowledgeCommitment>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral, std::size_t>>> + knowledge_commitment, KnowledgeCommitment>> &filled_kc_vector) { std::vector result; diff --git a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/assignment_table.hpp b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/assignment_table.hpp index c79ea433ac..dbe9f483d0 100644 --- a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/assignment_table.hpp +++ b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/assignment_table.hpp @@ -110,42 +110,32 @@ namespace nil { nil::marshalling::types::integral, // usable_rows nil::marshalling::types::integral, // rows_amount // witnesses - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - field_element, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral> + field_element >, // public_inputs - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - field_element, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral> + field_element >, // constants - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - field_element, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral> + field_element >, // selectors - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - field_element, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral> + field_element > > >; template - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< nil::marshalling::field_type, - field_element, FieldValueType>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral, std::size_t>>> + field_element, FieldValueType>> fill_field_element_vector_from_columns_with_padding( const std::vector> &columns, const std::size_t size, @@ -153,11 +143,9 @@ namespace nil { using TTypeBase = nil::marshalling::field_type; using field_element_type = field_element; - using field_element_vector_type = nil::marshalling::types::array_list< + using field_element_vector_type = nil::marshalling::types::standard_array_list< TTypeBase, - field_element_type, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>; + field_element_type>; field_element_vector_type result; result.value().reserve(size * columns.size()); @@ -174,11 +162,9 @@ namespace nil { template std::vector> make_field_element_columns_vector( - const nil::marshalling::types::array_list< + const nil::marshalling::types::standard_array_list< nil::marshalling::field_type, - field_element, FieldValueType>, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral, std::size_t>>> + field_element, FieldValueType>> &field_elem_vector, const std::size_t columns_amount, const std::size_t rows_amount) { diff --git a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/constraint.hpp b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/constraint.hpp index 6e957b8347..63ca335335 100644 --- a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/constraint.hpp +++ b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/constraint.hpp @@ -62,10 +62,9 @@ namespace nil { /*********************** Vector of plonk constraints as an input to gate ****************************/ template - using plonk_constraints = nil::marshalling::types::array_list< + using plonk_constraints = nil::marshalling::types::standard_array_list< TTypeBase, - plonk_constraint, - nil::marshalling::option::sequence_size_field_prefix> + plonk_constraint >; template diff --git a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/constraint_system.hpp b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/constraint_system.hpp index c98599f975..35dc11e69e 100644 --- a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/constraint_system.hpp +++ b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/constraint_system.hpp @@ -50,11 +50,7 @@ namespace nil { namespace types { template using public_input_sizes_type = - nil::marshalling::types::array_list< - TTypeBase, - nil::marshalling::types::integral, - nil::marshalling::option::sequence_size_field_prefix> - >; + nil::marshalling::types::standard_size_t_array_list; template using plonk_constraint_system = nil::marshalling::types::bundle< diff --git a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/copy_constraint.hpp b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/copy_constraint.hpp index 26c33aac93..e3d618eefb 100644 --- a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/copy_constraint.hpp +++ b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/copy_constraint.hpp @@ -54,10 +54,9 @@ namespace nil { // *********************** Plonk copy constraints **************************** // template - using plonk_copy_constraints = nil::marshalling::types::array_list< + using plonk_copy_constraints = nil::marshalling::types::standard_array_list< TTypeBase, - plonk_copy_constraint, - nil::marshalling::option::sequence_size_field_prefix> + plonk_copy_constraint >; template diff --git a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/gate.hpp b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/gate.hpp index e8402cce08..0687f28224 100644 --- a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/gate.hpp +++ b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/gate.hpp @@ -48,11 +48,9 @@ namespace nil { // std::size_t selector_index nil::marshalling::types::integral, // std::vector> constraints - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - plonk_constraint, - nil::marshalling::option::sequence_size_field_prefix - > + plonk_constraint > > >; @@ -64,9 +62,8 @@ namespace nil { using size_t_marshalling_type = nil::marshalling::types::integral; using constraint_marshalling_type = plonk_constraint; - using constraint_vector_marshalling_type = nil::marshalling::types::array_list< - TTypeBase, constraint_marshalling_type, - nil::marshalling::option::sequence_size_field_prefix>; + using constraint_vector_marshalling_type = nil::marshalling::types::standard_array_list< + TTypeBase, constraint_marshalling_type>; constraint_vector_marshalling_type filled_constraints; for (const auto &constr : gate.constraints) { @@ -95,18 +92,14 @@ namespace nil { template using plonk_gates = - nil::marshalling::types::array_list, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>; + nil::marshalling::types::standard_array_list>; template plonk_gates, PlonkGate> fill_plonk_gates(const InputRange &gates) { using TTypeBase = nil::marshalling::field_type; - using result_type = nil::marshalling::types::array_list< - TTypeBase, plonk_gate, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>; + using result_type = nil::marshalling::types::standard_array_list< + TTypeBase, plonk_gate>; result_type filled_gates; for (const auto &gate : gates) { diff --git a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/lookup_constraint.hpp b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/lookup_constraint.hpp index d4273c9f82..2233801c1d 100644 --- a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/lookup_constraint.hpp +++ b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/lookup_constraint.hpp @@ -73,10 +73,9 @@ namespace nil { // *********************** Vector of lookup constraints for a lookup gate **************************** // template - using plonk_lookup_constraints = nil::marshalling::types::array_list< + using plonk_lookup_constraints = nil::marshalling::types::standard_array_list< TTypeBase, - plonk_lookup_constraint, - nil::marshalling::option::sequence_size_field_prefix> + plonk_lookup_constraint >; template diff --git a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/lookup_gate.hpp b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/lookup_gate.hpp index 756c558eb0..e4d058f6c8 100644 --- a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/lookup_gate.hpp +++ b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/lookup_gate.hpp @@ -48,11 +48,9 @@ namespace nil { // std::size_t selector_index nil::marshalling::types::integral, // std::vector> constraints - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - plonk_lookup_constraint, - nil::marshalling::option::sequence_size_field_prefix - > + plonk_lookup_constraint > > >; @@ -64,9 +62,8 @@ namespace nil { using size_t_marshalling_type = nil::marshalling::types::integral; using constraint_marshalling_type = plonk_lookup_constraint; - using constraint_vector_marshalling_type = nil::marshalling::types::array_list< - TTypeBase, constraint_marshalling_type, - nil::marshalling::option::sequence_size_field_prefix>; + using constraint_vector_marshalling_type = nil::marshalling::types::standard_array_list< + TTypeBase, constraint_marshalling_type>; constraint_vector_marshalling_type filled_constraints; for (const auto &constr : gate.constraints) { @@ -95,19 +92,16 @@ namespace nil { template using plonk_lookup_gates = - nil::marshalling::types::array_list< - TTypeBase, plonk_lookup_gate, - nil::marshalling::option::sequence_size_field_prefix> + nil::marshalling::types::standard_array_list< + TTypeBase, plonk_lookup_gate >; template plonk_lookup_gates, PlonkGate> fill_plonk_lookup_gates(const InputRange &gates) { using TTypeBase = nil::marshalling::field_type; - using result_type = nil::marshalling::types::array_list< - TTypeBase, plonk_lookup_gate, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>; + using result_type = nil::marshalling::types::standard_array_list< + TTypeBase, plonk_lookup_gate>; result_type filled_gates; for (const auto &gate : gates) { diff --git a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/lookup_table.hpp b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/lookup_table.hpp index 6659d2d60c..602bf07c4c 100644 --- a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/lookup_table.hpp +++ b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/lookup_table.hpp @@ -47,10 +47,9 @@ namespace nil { nil::marshalling::types::integral, // tag_index nil::marshalling::types::integral, // columns_number - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - typename variable::type, - nil::marshalling::option::sequence_size_field_prefix> + typename variable::type > > >; @@ -61,10 +60,9 @@ namespace nil { using TTypeBase = nil::marshalling::field_type; using variable_type = typename LookupTable::variable_type; - nil::marshalling::types::array_list< + nil::marshalling::types::standard_array_list< TTypeBase, - typename variable::type, - nil::marshalling::option::sequence_size_field_prefix> + typename variable::type > filled_options; for( std::size_t i = 0; i < table.lookup_options.size(); i++ ){ @@ -112,19 +110,16 @@ namespace nil { template using plonk_lookup_tables = - nil::marshalling::types::array_list< - TTypeBase, plonk_lookup_table, - nil::marshalling::option::sequence_size_field_prefix> + nil::marshalling::types::standard_array_list< + TTypeBase, plonk_lookup_table >; template plonk_lookup_tables, PlonkTable> fill_plonk_lookup_tables(const InputRange &tables) { using TTypeBase = nil::marshalling::field_type; - using result_type = nil::marshalling::types::array_list< - TTypeBase, plonk_lookup_table, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>; + using result_type = nil::marshalling::types::standard_array_list< + TTypeBase, plonk_lookup_table>; result_type filled_tables; for (const auto &table : tables) { diff --git a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/variable.hpp b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/variable.hpp index d00f411f5f..58af1708e8 100644 --- a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/variable.hpp +++ b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/plonk/variable.hpp @@ -91,10 +91,9 @@ namespace nil { //****************** vector of plonk_variable *************************/ template - using variables = nil::marshalling::types::array_list< + using variables = nil::marshalling::types::standard_array_list< TTypeBase, - typename variable::type, - nil::marshalling::option::sequence_size_field_prefix> + typename variable::type >; template diff --git a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/sparse_vector.hpp b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/sparse_vector.hpp index f4d899080c..a5c8192416 100644 --- a/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/sparse_vector.hpp +++ b/crypto3/libs/marshalling/zk/include/nil/crypto3/marshalling/zk/types/sparse_vector.hpp @@ -60,17 +60,14 @@ namespace nil { typename... TOptions> using sparse_vector = nil::marshalling::types::bundle< TTypeBase, - std::tuple, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>, - nil::marshalling::types::array_list< - TTypeBase, - curve_element, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>, - nil::marshalling::types::integral>>; + std::tuple< + nil::marshalling::types::standard_size_t_array_list, + nil::marshalling::types::standard_array_list< + TTypeBase, + curve_element>, + nil::marshalling::types::integral + > + >; template using knowledge_commitment_sparse_vector = nil::marshalling::types::bundle< TTypeBase, - std::tuple, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>, - nil::marshalling::types::array_list< - TTypeBase, - knowledge_commitment, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>, - nil::marshalling::types::integral>>; + std::tuple< + nil::marshalling::types::standard_size_t_array_list, + nil::marshalling::types::standard_array_list< + TTypeBase, + knowledge_commitment>, + nil::marshalling::types::integral + > + >; template using fast_knowledge_commitment_sparse_vector = nil::marshalling::types::bundle< TTypeBase, - std::tuple, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>, - nil::marshalling::types::array_list< - TTypeBase, - fast_knowledge_commitment, - nil::marshalling::option::sequence_size_field_prefix< - nil::marshalling::types::integral>>, - nil::marshalling::types::integral>>; + std::tuple< + nil::marshalling::types::standard_size_t_array_list, + nil::marshalling::types::standard_array_list< + TTypeBase, + fast_knowledge_commitment>, + nil::marshalling::types::integral + > + >; template sparse_vector, SparseVector> @@ -121,10 +112,7 @@ namespace nil { using TTypeBase = nil::marshalling::field_type; using integral_type = nil::marshalling::types::integral; - using integral_vector_type = nil::marshalling::types::array_list< - TTypeBase, - integral_type, - nil::marshalling::option::sequence_size_field_prefix>; + using integral_vector_type = nil::marshalling::types::standard_size_t_array_list; integral_vector_type filled_indices; @@ -173,10 +161,7 @@ namespace nil { using TTypeBase = nil::marshalling::field_type; using integral_type = nil::marshalling::types::integral; - using integral_vector_type = nil::marshalling::types::array_list< - TTypeBase, - integral_type, - nil::marshalling::option::sequence_size_field_prefix>; + using integral_vector_type = nil::marshalling::types::standard_size_t_array_list; integral_vector_type filled_indices; @@ -228,11 +213,8 @@ namespace nil { using TTypeBase = nil::marshalling::field_type; using integral_type = nil::marshalling::types::integral; - using integral_vector_type = nil::marshalling::types::array_list< - TTypeBase, - integral_type, - nil::marshalling::option::sequence_size_field_prefix>; - + using integral_vector_type = nil::marshalling::types::standard_size_t_array_list; + integral_vector_type filled_indices; std::vector &filled_indices_val = filled_indices.value(); diff --git a/crypto3/readme.md b/crypto3/readme.md index 9fc940a37e..e4b077834f 100644 --- a/crypto3/readme.md +++ b/crypto3/readme.md @@ -35,25 +35,14 @@ root ├── docs: documentation , tutorials and guides ├── libs: all directories added as submodules which are independent projects. │ ├── algebra: algebraic operations and structures being used for elliptic-curve cryptography -│ ├── block: block ciphers +│ ├── benchmark_tools: utilities to run benchmarks │ ├── blueprint: components and circuits for zk schemes -│ ├── codec: encoding/decoding algorithms │ ├── containers: containers and generic commitment schemes for accumulating data, includes Merkle Tree │ ├── hash: hashing algorithms -│ ├── kdf: key derivation functions -│ ├── mac: message authentication codes │ ├── marshalling: marshalling libraries for types in crypto3 library │ ├── math: set of Fast Fourier Transforms evaluation algorithms and Polynomial Arithmetics -│ ├── modes: cipher modes │ ├── multiprecision: integer, rational, floating-point, complex and interval number types. -│ ├── passhash: password hashing operations -│ ├── pbkdf: password based key derivation functions -│ ├── pkmodes: threshold, aggregation modes for public key schemes -│ ├── pkpad: padding module for public key schemes -│ ├── pubkey: pubkey signing APIs │ ├── random: randomisation primitives -│ ├── stream: stream ciphers -│ ├── vdf: verifiable delay functions │ ├── zk: zk cryptography schemes ``` @@ -121,24 +110,6 @@ The generic module can be added to your c++ project as follows ``` git submodule add https://github.com/NilFoundation/crypto3.git ``` -### Selective -Developer can select to include a one or more modules to reduce the sources of resulting project and dependencies tree height. This however -does require the developer to manually resolve all required dependencies and stay upto date regarding -compatibilities across modules. - -Example of such embedding is =nil; Foundation's [Actor Library](https://github.com/nilfoundation/actor). It uses only -[hashes](https://github.com/nilfoundation/hash) so the dependency graph requires -for the project to submodule [block ciphers library](https://github.com/nilfoundation/block) and optional -[codec library](https://github.com/nilfoundation/codec) for testing purposes. So, -the root Actor repository has only related libraries submoduled: -[block](https://github.com/nilfoundation/mtl/libs/block), -[codec](https://github.com/nilfoundation/mtl/libs/codec) and -[hash](https://github.com/nilfoundation/mtl/hash). - -Selective modules can be added to your project as follows: - -``` git submodule add https://github.com/NilFoundation/crypto3-.git ``` - ## Contributing diff --git a/flake.nix b/flake.nix index e6ef341770..d493d0340b 100644 --- a/flake.nix +++ b/flake.nix @@ -50,6 +50,12 @@ runTests = false; enableDebug = true; }); + crypto3-clang-debug-tests = (pkgs.callPackage ./crypto3.nix { + stdenv = pkgs.llvmPackages_19.stdenv; + runTests = true; + enableDebug = true; + }); + parallel-crypto3 = (pkgs.callPackage ./parallel-crypto3.nix { runTests = false;