diff --git a/include/nil/crypto3/zk/commitments/polynomial/kzg.hpp b/include/nil/crypto3/zk/commitments/polynomial/kzg.hpp index 9f31137b..7906c942 100644 --- a/include/nil/crypto3/zk/commitments/polynomial/kzg.hpp +++ b/include/nil/crypto3/zk/commitments/polynomial/kzg.hpp @@ -325,7 +325,7 @@ namespace nil { static void update_transcript(const typename KZG::public_key_type &public_key, typename KZG::transcript_type &transcript) { - /* The procedure of updating the transcript is subject to review and change + /* The procedure of updating the transcript is subject to review and change * #295 */ nil::marshalling::status_type status; @@ -671,7 +671,7 @@ namespace nil { } void update_transcript(std::size_t batch_ind, typename KZGScheme::transcript_type &transcript) { - /* The procedure of updating the transcript is subject to review and change + /* The procedure of updating the transcript is subject to review and change * #295 */ // Push commitments to transcript @@ -849,7 +849,7 @@ namespace nil { typename KZGScheme::commitment_type, typename KZGScheme::poly_type> { public: - constexpr static bool is_kzg_commitment_scheme_v2 = true; + static constexpr bool is_kzg(){ return true; } using curve_type = typename KZGScheme::curve_type; using field_type = typename KZGScheme::field_type; @@ -912,7 +912,7 @@ namespace nil { } void update_transcript(std::size_t batch_ind, typename KZGScheme::transcript_type &transcript) { - /* The procedure of updating the transcript is subject to review and change + /* The procedure of updating the transcript is subject to review and change * #295 */ // Push commitments to transcript diff --git a/include/nil/crypto3/zk/commitments/polynomial/lpc.hpp b/include/nil/crypto3/zk/commitments/polynomial/lpc.hpp index d9854139..3c0be06b 100644 --- a/include/nil/crypto3/zk/commitments/polynomial/lpc.hpp +++ b/include/nil/crypto3/zk/commitments/polynomial/lpc.hpp @@ -52,6 +52,8 @@ namespace nil { typename LPCScheme::commitment_type, PolynomialType>{ public: + static constexpr bool is_lpc(){return true;} + using field_type = typename LPCScheme::field_type; using value_type = typename field_type::value_type; using params_type = typename LPCScheme::params_type; @@ -67,8 +69,6 @@ namespace nil { using eval_storage_type = typename LPCScheme::eval_storage_type; using preprocessed_data_type = std::map>; - constexpr static bool is_lpc = true; - private: std::map _trees; typename fri_type::params_type _fri_params; diff --git a/include/nil/crypto3/zk/commitments/type_traits.hpp b/include/nil/crypto3/zk/commitments/type_traits.hpp index b1217643..17e29d79 100644 --- a/include/nil/crypto3/zk/commitments/type_traits.hpp +++ b/include/nil/crypto3/zk/commitments/type_traits.hpp @@ -98,6 +98,45 @@ namespace nil { constexpr static const bool value = !std::is_same(nullptr))>::value; }; + template + class has_available_static_member_function_is_kzg { + struct no { }; + + protected: + template + static void test(std::nullptr_t) { + struct t { + using C::is_kzg; + }; + } + + template + static no test(...); + + public: + constexpr static const bool value = !std::is_same(nullptr))>::value; + }; + + template + class has_available_static_member_function_is_lpc { + struct no { }; + + protected: + template + + static void test(std::nullptr_t) { + struct t { + using C::is_lpc; + }; + } + + template + static no test(...); + + public: + constexpr static const bool value = !std::is_same(nullptr))>::value; + }; + template struct is_commitment { using commitment_type = typename member_type_commitment_type::type; @@ -109,12 +148,41 @@ namespace nil { typedef T type; }; + // An idea was copied from this example: + // https://stackoverflow.com/questions/54920801/check-if-static-function-is-available-in-class-at-compile-time + + template + struct is_kzg_struct: std::false_type{ + static const bool value = false; + }; + + template + struct is_kzg_struct::value>> + : std::integral_constant + {}; + + template + constexpr bool is_kzg = is_kzg_struct::value; + + + template + struct is_lpc_struct: std::false_type{ + static const bool value = false; + }; + + template + struct is_lpc_struct::value>> + : std::integral_constant + {}; + + template + constexpr bool is_lpc = is_lpc_struct::value; + template struct select_container { using type = typename std:: conditional, std::vector>::type; }; - } // namespace zk } // namespace crypto3 } // namespace nil