Skip to content

Commit

Permalink
PLONK blueprint test separated. #16
Browse files Browse the repository at this point in the history
  • Loading branch information
nkaskov committed Dec 24, 2021
1 parent 3451b64 commit 3134364
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 5 deletions.
7 changes: 6 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ macro(define_blueprint_test test)
endif()
endmacro()

set(BLUEPRINT_TESTS_FILES
"blueprint/plonk"
)

set(PLONK_TESTS_FILES
"algebra/plonk/fixed_base_scalar_mul_5_wires"
)
Expand Down Expand Up @@ -99,7 +103,8 @@ SET(ALGEBRA_TESTS_FILES
${FIELDS_TESTS_FILES}
${PAIRING_TESTS_FILES})

SET(ALL_TESTS_FILES
SET(ALL_TESTS_FILES
${BLUEPRINT_TESTS_FILES}
${PLONK_TESTS_FILES}
${ALGEBRA_TESTS_FILES}
${HASHES_TESTS_FILES}
Expand Down
4 changes: 0 additions & 4 deletions test/algebra/plonk/fixed_base_scalar_mul_5_wires.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ BOOST_AUTO_TEST_CASE(fixed_base_scalar_mul_5_wires_test_case) {

zk::components::blueprint<TArithmetization> bp;

BOOST_CHECK_EQUAL(0, bp.allocate_rows());
BOOST_CHECK_EQUAL(1, bp.allocate_rows(5));
BOOST_CHECK_EQUAL(6, bp.allocate_rows());

using component_type = zk::components::element_g1_fixed_base_scalar_mul<curve_type, TArithmetization>;

component_type scalar_mul_component(bp, B);
Expand Down
55 changes: 55 additions & 0 deletions test/blueprint/plonk.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2022 Mikhail Komarov <nemo@nil.foundation>
// Copyright (c) 2022 Nikita Kaskov <nbering@nil.foundation>
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//---------------------------------------------------------------------------//

#define BOOST_TEST_MODULE blueprint_plonk_test

#include <boost/test/unit_test.hpp>

#include <nil/crypto3/algebra/curves/bls12.hpp>
#include <nil/crypto3/algebra/fields/arithmetic_params/bls12.hpp>
#include <nil/crypto3/algebra/curves/params/multiexp/bls12.hpp>
#include <nil/crypto3/algebra/curves/params/wnaf/bls12.hpp>

#include <nil/crypto3/zk/components/blueprint.hpp>

using namespace nil::crypto3;

BOOST_AUTO_TEST_SUITE(blueprint_plonk_test_suite)

BOOST_AUTO_TEST_CASE(blueprint_plonk_allocat_rows_test_case) {

using curve_type = algebra::curves::bls12<381>;
using TBlueprintField = typename curve_type::base_field_type;
constexpr std::size_t WiresAmount = 5;
using TArithmetization = zk::snark::plonk_constraint_system<TBlueprintField, WiresAmount>;

zk::components::blueprint<TArithmetization> bp;

BOOST_CHECK_EQUAL(0, bp.allocate_rows());
BOOST_CHECK_EQUAL(1, bp.allocate_rows(5));
BOOST_CHECK_EQUAL(6, bp.allocate_rows());
}

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 3134364

Please sign in to comment.