-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
779 additions
and
133 deletions.
There are no files selected for viewing
231 changes: 165 additions & 66 deletions
231
include/nil/crypto3/zk/components/non_native/algebra/fields/plonk/addition.hpp
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
295 changes: 295 additions & 0 deletions
295
include/nil/crypto3/zk/components/non_native/algebra/fields/plonk/subtraction.hpp
Large diffs are not rendered by default.
Oops, something went wrong.
290 changes: 225 additions & 65 deletions
290
include/nil/crypto3/zk/components/non_native/algebra/fields/plonk/sum_of_squares_and_c.hpp
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
//---------------------------------------------------------------------------// | ||
// Copyright (c) 2021-2022 Mikhail Komarov <nemo@nil.foundation> | ||
// Copyright (c) 2021-2022 Nikita Kaskov <nbering@nil.foundation> | ||
// Copyright (c) 2022 Alisa Cherniaeva <a.cherniaeva@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_non_native_field_test | ||
|
||
#include <boost/test/unit_test.hpp> | ||
|
||
#include <nil/crypto3/algebra/curves/pallas.hpp> | ||
#include <nil/crypto3/algebra/fields/arithmetic_params/pallas.hpp> | ||
|
||
#include <nil/crypto3/algebra/curves/curve25519.hpp> | ||
#include <nil/crypto3/algebra/fields/arithmetic_params/ed25519.hpp> | ||
|
||
#include <nil/crypto3/hash/algorithm/hash.hpp> | ||
#include <nil/crypto3/hash/sha2.hpp> | ||
#include <nil/crypto3/hash/keccak.hpp> | ||
|
||
#include <nil/crypto3/zk/snark/arithmetization/plonk/params.hpp> | ||
|
||
#include <nil/crypto3/zk/blueprint/plonk.hpp> | ||
#include <nil/crypto3/zk/assignment/plonk.hpp> | ||
#include <nil/crypto3/zk/components/non_native/algebra/fields/plonk/addition.hpp> | ||
|
||
#include "../../test_plonk_component.hpp" | ||
|
||
using namespace nil::crypto3; | ||
|
||
BOOST_AUTO_TEST_SUITE(blueprint_plonk_test_suite) | ||
|
||
BOOST_AUTO_TEST_CASE(blueprint_non_native_addition) { | ||
auto start = std::chrono::high_resolution_clock::now(); | ||
|
||
using curve_type = algebra::curves::pallas; | ||
using ed25519_type = algebra::curves::curve25519; | ||
using BlueprintFieldType = typename curve_type::base_field_type; | ||
constexpr std::size_t WitnessColumns = 9; | ||
constexpr std::size_t PublicInputColumns = 1; | ||
constexpr std::size_t ConstantColumns = 0; | ||
constexpr std::size_t SelectorColumns = 2; | ||
using ArithmetizationParams = | ||
zk::snark::plonk_arithmetization_params<WitnessColumns, PublicInputColumns, ConstantColumns, SelectorColumns>; | ||
using ArithmetizationType = zk::snark::plonk_constraint_system<BlueprintFieldType, ArithmetizationParams>; | ||
using hash_type = nil::crypto3::hashes::keccak_1600<256>; | ||
constexpr std::size_t Lambda = 1; | ||
|
||
using var = zk::snark::plonk_variable<BlueprintFieldType>; | ||
|
||
using component_type = zk::components::non_native_field_element_addition<ArithmetizationType, curve_type, ed25519_type, 0, 1, 2, 3, | ||
4, 5, 6, 7, 8>; | ||
|
||
std::array<var, 4> input_var_a = {var(0, 0, false, var::column_type::public_input), var(0, 1, false, var::column_type::public_input), | ||
var(0, 2, false, var::column_type::public_input), var(0, 3, false, var::column_type::public_input)}; | ||
std::array<var, 4> input_var_b = {var(0, 4, false, var::column_type::public_input), var(0, 5, false, var::column_type::public_input), | ||
var(0, 6, false, var::column_type::public_input), var(0, 7, false, var::column_type::public_input)}; | ||
|
||
typename component_type::params_type params = {input_var_a, input_var_b}; | ||
|
||
std::vector<typename BlueprintFieldType::value_type> public_input = {45524, 52353, 68769, 5431, 3724, 342453, 5425, 54222}; | ||
//std::vector<typename BlueprintFieldType::value_type> public_input = {1, 0, 0, 0, 1, 0, 0, 0}; | ||
|
||
test_component<component_type, BlueprintFieldType, ArithmetizationParams, hash_type, Lambda>(params, public_input); | ||
|
||
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - start); | ||
std::cout << "multiplication component : " << duration.count() << "ms" << std::endl; | ||
} | ||
|
||
BOOST_AUTO_TEST_SUITE_END() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters