From cd1fd2e600717492d80553df43b6ca97514b14c5 Mon Sep 17 00:00:00 2001 From: Polina Chernyshova Date: Sat, 11 Feb 2023 18:25:47 +0000 Subject: [PATCH] updated templates for functions #113 --- .../crypto3/zk/commitments/polynomial/kzg.hpp | 64 ++++++++++++++++--- 1 file changed, 55 insertions(+), 9 deletions(-) diff --git a/include/nil/crypto3/zk/commitments/polynomial/kzg.hpp b/include/nil/crypto3/zk/commitments/polynomial/kzg.hpp index a202186f5..b60cc7553 100644 --- a/include/nil/crypto3/zk/commitments/polynomial/kzg.hpp +++ b/include/nil/crypto3/zk/commitments/polynomial/kzg.hpp @@ -83,7 +83,12 @@ namespace nil { } // namespace commitments namespace algorithms { - template + template, + KZG>::value, + bool>::type = true> static typename KZG::params_type setup(std::size_t max_degree, typename KZG::scalar_value_type alpha) { typename KZG::scalar_value_type alpha_scaled = alpha; typename KZG::commitment_key_type commitment_key = {KZG::curve_type::template g1_type<>::value_type::one()}; @@ -98,7 +103,12 @@ namespace nil { return typename KZG::params_type(commitment_key, verification_key); } - template + template, + KZG>::value, + bool>::type = true> static typename KZG::commitment_type commit(const typename KZG::params_type ¶ms, const typename math::polynomial &f) { BOOST_ASSERT(f.size() <= params.commitment_key.size()); @@ -106,7 +116,12 @@ namespace nil { params.commitment_key.begin() + f.size(), f.begin(), f.end(), 1); } - template + template, + KZG>::value, + bool>::type = true> static typename KZG::proof_type proof_eval(typename KZG::params_type params, const typename math::polynomial &f, typename KZG::scalar_value_type i, @@ -125,7 +140,12 @@ namespace nil { return commit(params, q); } - template + template, + KZG>::value, + bool>::type = true> static bool verify_eval(typename KZG::params_type params, typename KZG::proof_type p, typename KZG::commitment_type C_f, @@ -165,6 +185,7 @@ namespace nil { struct batched_kzg : public kzg { typedef CurveType curve_type; + typedef KZGParams kzg_type; constexpr static const std::size_t batch_size = KZGParams::batch_size; typedef typename curve_type::gt_type::value_type gt_value_type; @@ -184,7 +205,12 @@ namespace nil { namespace algorithms { - template + template, + KZG>::value, + bool>::type = true> static typename math::polynomial accumulate(const std::vector> &polys, const typename KZG::scalar_value_type &factor) { std::size_t num = polys.size(); @@ -197,7 +223,12 @@ namespace nil { return result; } - template + template, + KZG>::value, + bool>::type = true> static typename KZG::evals_type evaluate_polynomials(const typename KZG::batch_of_batches_of_polynomials_type &polys, const std::vector zs) { @@ -215,7 +246,12 @@ namespace nil { return evals; } - template + template, + KZG>::value, + bool>::type = true> static std::vector commit(const typename KZG::params_type ¶ms, const std::vector> &polys) { std::vector commitments; @@ -225,7 +261,12 @@ namespace nil { return commitments; } - template + template, + KZG>::value, + bool>::type = true> static typename KZG::batched_proof_type proof_eval(const typename KZG::params_type ¶ms, const typename KZG::batch_of_batches_of_polynomials_type &polys, const typename KZG::evals_type &evals, @@ -246,7 +287,12 @@ namespace nil { return proofs; } - template + template, + KZG>::value, + bool>::type = true> static bool verify_eval(typename KZG::params_type params, const typename KZG::batched_proof_type &proof, const typename KZG::evals_type &evals,