From 1422800c086bbacf7ce14656984db9a63152ed58 Mon Sep 17 00:00:00 2001 From: Polina Chernyshova Date: Tue, 7 Feb 2023 13:58:08 +0000 Subject: [PATCH] minor updates #113 --- include/nil/crypto3/zk/commitments/polynomial/kzg.hpp | 9 +++++---- test/commitment/kzg.cpp | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/nil/crypto3/zk/commitments/polynomial/kzg.hpp b/include/nil/crypto3/zk/commitments/polynomial/kzg.hpp index 802ad97ee..0fc6d2812 100644 --- a/include/nil/crypto3/zk/commitments/polynomial/kzg.hpp +++ b/include/nil/crypto3/zk/commitments/polynomial/kzg.hpp @@ -43,10 +43,11 @@ #include #include -using namespace nil::crypto3::math; - #include +using namespace nil::crypto3; +using namespace nil::crypto3::math; + namespace nil { namespace crypto3 { namespace zk { @@ -73,7 +74,7 @@ namespace nil { scalar_value_type alpha; //secret key kzg_params_type(std::size_t _n, scalar_value_type _alpha) : n(_n), alpha(_alpha) {} kzg_params_type(std::size_t _n) { - alpha = scalar_value_type::random_element(); + alpha = algebra::random_element(); n = _n; } }; @@ -101,7 +102,7 @@ namespace nil { static commitment_type commit(const srs_type &srs, const polynomial &f) { - // assert(f.size() <= srs.commitment_key.size()); + assert(f.size() <= srs.commitment_key.size()); return algebra::multiexp(srs.commitment_key.begin(), srs.commitment_key.begin() + f.size(), f.begin(), f.end(), 1); } diff --git a/test/commitment/kzg.cpp b/test/commitment/kzg.cpp index 706970e0d..451c5a5ba 100644 --- a/test/commitment/kzg.cpp +++ b/test/commitment/kzg.cpp @@ -97,12 +97,12 @@ BOOST_AUTO_TEST_CASE(kzg_random_test) { typedef typename curve_type::scalar_field_type::value_type scalar_value_type; typedef zk::commitments::kzg_commitment kzg_type; - scalar_value_type alpha = algebra::random_element(); scalar_value_type i = algebra::random_element(); std::size_t n = 298; const polynomial f = {-1, 1, 2, 3, 5, -15}; - auto srs = kzg_type::setup({n, alpha}); + auto kzg_params = kzg_type::kzg_params_type(n); + auto srs = kzg_type::setup(kzg_params); auto commit = kzg_type::commit(srs, f); auto eval = f.evaluate(i); auto proof = kzg_type::proof_eval(srs, f, i, eval); @@ -232,7 +232,6 @@ BOOST_AUTO_TEST_CASE(kzg_batched_random_test) { typedef typename curve_type::scalar_field_type::value_type scalar_value_type; typedef zk::commitments::kzg_batched_commitment kzg_type; - scalar_value_type alpha = algebra::random_element(); std::size_t n = 298; const std::vector> f0{{ {{1, 2, 3, 4, 5, 6, 7, 8}}, @@ -259,7 +258,9 @@ BOOST_AUTO_TEST_CASE(kzg_batched_random_test) { } auto evals = kzg_type::evaluate_polynomials(polys, zs); - auto srs = kzg_type::setup({n, alpha}); + auto kzg_params = kzg_type::kzg_params_type(n); + auto alpha = kzg_params.alpha; + auto srs = kzg_type::setup(kzg_params); std::vector gammas; for (std::size_t i = 0; i < num_polys; ++i) {