-
Notifications
You must be signed in to change notification settings - Fork 18
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
1 changed file
with
27 additions
and
26 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
//---------------------------------------------------------------------------// | ||
// Copyright (c) 2023 Alexey Yashunsky <[email protected]> | ||
// Copyright (c) 2024 Vasiliy Olekhov <[email protected]> | ||
// | ||
// MIT License | ||
// | ||
|
@@ -26,8 +27,8 @@ | |
// F_p^2 = F_p[u]/(u^2 - (-1)) and a a non-cubic residue. | ||
//---------------------------------------------------------------------------// | ||
|
||
#ifndef CRYPTO3_BLUEPRINT_COMPONENTS_PLONK_BLS12_G2_POINT_ADDITION_HPP | ||
#define CRYPTO3_BLUEPRINT_COMPONENTS_PLONK_BLS12_G2_POINT_ADDITION_HPP | ||
#ifndef CRYPTO3_BLUEPRINT_COMPONENTS_PLONK_MNT6_G2_POINT_ADDITION_HPP | ||
#define CRYPTO3_BLUEPRINT_COMPONENTS_PLONK_MNT6_G2_POINT_ADDITION_HPP | ||
|
||
#include <nil/crypto3/zk/snark/arithmetization/plonk/constraint_system.hpp> | ||
|
||
|
@@ -59,10 +60,10 @@ namespace nil { | |
// | ||
|
||
template<typename ArithmetizationType> | ||
class bls12_g2_point_addition; | ||
class mnt6_g2_point_addition; | ||
|
||
template<typename BlueprintFieldType> | ||
class bls12_g2_point_addition<crypto3::zk::snark::plonk_constraint_system<BlueprintFieldType>> | ||
class mnt6_g2_point_addition<crypto3::zk::snark::plonk_constraint_system<BlueprintFieldType>> | ||
: public plonk_component<BlueprintFieldType> { | ||
|
||
public: | ||
|
@@ -74,7 +75,7 @@ namespace nil { | |
class gate_manifest_type : public component_gate_manifest { | ||
public: | ||
std::uint32_t gates_amount() const override { | ||
return bls12_g2_point_addition::gates_amount; | ||
return mnt6_g2_point_addition::gates_amount; | ||
} | ||
}; | ||
|
||
|
@@ -115,7 +116,7 @@ namespace nil { | |
struct result_type { | ||
std::array<var,4> R; | ||
|
||
result_type(const bls12_g2_point_addition &component, std::uint32_t start_row_index) { | ||
result_type(const mnt6_g2_point_addition &component, std::uint32_t start_row_index) { | ||
const std::size_t WA = component.witness_amount(); | ||
|
||
for(std::size_t i = 0; i < 4; i++) { | ||
|
@@ -132,15 +133,15 @@ namespace nil { | |
}; | ||
|
||
template<typename ContainerType> | ||
explicit bls12_g2_point_addition(ContainerType witness) : component_type(witness, {}, {}, get_manifest()) {}; | ||
explicit mnt6_g2_point_addition(ContainerType witness) : component_type(witness, {}, {}, get_manifest()) {}; | ||
|
||
template<typename WitnessContainerType, typename ConstantContainerType, | ||
typename PublicInputContainerType> | ||
bls12_g2_point_addition(WitnessContainerType witness, ConstantContainerType constant, | ||
mnt6_g2_point_addition(WitnessContainerType witness, ConstantContainerType constant, | ||
PublicInputContainerType public_input) : | ||
component_type(witness, constant, public_input, get_manifest()) {}; | ||
|
||
bls12_g2_point_addition( | ||
mnt6_g2_point_addition( | ||
std::initializer_list<typename component_type::witness_container_type::value_type> | ||
witnesses, | ||
std::initializer_list<typename component_type::constant_container_type::value_type> | ||
|
@@ -151,16 +152,16 @@ namespace nil { | |
}; | ||
|
||
template<typename BlueprintFieldType> | ||
using plonk_bls12_g2_point_addition = | ||
bls12_g2_point_addition< | ||
using plonk_mnt6_g2_point_addition = | ||
mnt6_g2_point_addition< | ||
crypto3::zk::snark::plonk_constraint_system<BlueprintFieldType>>; | ||
|
||
template<typename BlueprintFieldType> | ||
typename plonk_bls12_g2_point_addition<BlueprintFieldType>::result_type generate_assignments( | ||
const plonk_bls12_g2_point_addition<BlueprintFieldType> &component, | ||
typename plonk_mnt6_g2_point_addition<BlueprintFieldType>::result_type generate_assignments( | ||
const plonk_mnt6_g2_point_addition<BlueprintFieldType> &component, | ||
assignment<crypto3::zk::snark::plonk_constraint_system<BlueprintFieldType>> | ||
&assignment, | ||
const typename plonk_bls12_g2_point_addition<BlueprintFieldType>::input_type | ||
const typename plonk_mnt6_g2_point_addition<BlueprintFieldType>::input_type | ||
&instance_input, | ||
const std::uint32_t start_row_index) { | ||
|
||
|
@@ -221,22 +222,22 @@ namespace nil { | |
assignment.witness(component.W((22 + i) % WA),start_row_index + (WA < 24)) = yR.data[i]; | ||
} | ||
|
||
return typename plonk_bls12_g2_point_addition<BlueprintFieldType>::result_type( | ||
return typename plonk_mnt6_g2_point_addition<BlueprintFieldType>::result_type( | ||
component, start_row_index); | ||
} | ||
|
||
template<typename BlueprintFieldType> | ||
std::size_t generate_gates( | ||
const plonk_bls12_g2_point_addition<BlueprintFieldType> &component, | ||
const plonk_mnt6_g2_point_addition<BlueprintFieldType> &component, | ||
circuit<crypto3::zk::snark::plonk_constraint_system<BlueprintFieldType>> &bp, | ||
assignment<crypto3::zk::snark::plonk_constraint_system<BlueprintFieldType>> | ||
&assignment, | ||
const typename plonk_bls12_g2_point_addition<BlueprintFieldType>::input_type | ||
const typename plonk_mnt6_g2_point_addition<BlueprintFieldType>::input_type | ||
&instance_input) { | ||
|
||
const std::size_t WA = component.witness_amount(); | ||
|
||
using var = typename plonk_bls12_g2_point_addition<BlueprintFieldType>::var; | ||
using var = typename plonk_mnt6_g2_point_addition<BlueprintFieldType>::var; | ||
using constraint_type = crypto3::zk::snark::plonk_constraint<BlueprintFieldType>; | ||
|
||
// Fp2 field over constraints: | ||
|
@@ -326,14 +327,14 @@ namespace nil { | |
|
||
template<typename BlueprintFieldType> | ||
void generate_copy_constraints( | ||
const plonk_bls12_g2_point_addition<BlueprintFieldType> &component, | ||
const plonk_mnt6_g2_point_addition<BlueprintFieldType> &component, | ||
circuit<crypto3::zk::snark::plonk_constraint_system<BlueprintFieldType>> &bp, | ||
assignment<crypto3::zk::snark::plonk_constraint_system<BlueprintFieldType>> | ||
&assignment, | ||
const typename plonk_bls12_g2_point_addition<BlueprintFieldType>::input_type &instance_input, | ||
const typename plonk_mnt6_g2_point_addition<BlueprintFieldType>::input_type &instance_input, | ||
const std::size_t start_row_index) { | ||
|
||
using var = typename plonk_bls12_g2_point_addition<BlueprintFieldType>::var; | ||
using var = typename plonk_mnt6_g2_point_addition<BlueprintFieldType>::var; | ||
|
||
const std::size_t WA = component.witness_amount(); | ||
|
||
|
@@ -343,12 +344,12 @@ namespace nil { | |
} | ||
|
||
template<typename BlueprintFieldType> | ||
typename plonk_bls12_g2_point_addition<BlueprintFieldType>::result_type generate_circuit( | ||
const plonk_bls12_g2_point_addition<BlueprintFieldType> &component, | ||
typename plonk_mnt6_g2_point_addition<BlueprintFieldType>::result_type generate_circuit( | ||
const plonk_mnt6_g2_point_addition<BlueprintFieldType> &component, | ||
circuit<crypto3::zk::snark::plonk_constraint_system<BlueprintFieldType>> &bp, | ||
assignment<crypto3::zk::snark::plonk_constraint_system<BlueprintFieldType>> | ||
&assignment, | ||
const typename plonk_bls12_g2_point_addition<BlueprintFieldType>::input_type &instance_input, | ||
const typename plonk_mnt6_g2_point_addition<BlueprintFieldType>::input_type &instance_input, | ||
const std::size_t start_row_index) { | ||
|
||
std::size_t selector_index = generate_gates(component, bp, assignment, instance_input); | ||
|
@@ -357,12 +358,12 @@ namespace nil { | |
|
||
generate_copy_constraints(component, bp, assignment, instance_input, start_row_index); | ||
|
||
return typename plonk_bls12_g2_point_addition<BlueprintFieldType>::result_type( | ||
return typename plonk_mnt6_g2_point_addition<BlueprintFieldType>::result_type( | ||
component, start_row_index); | ||
} | ||
|
||
} // namespace components | ||
} // namespace blueprint | ||
} // namespace nil | ||
|
||
#endif // CRYPTO3_BLUEPRINT_COMPONENTS_PLONK_BLS12_G2_POINT_ADDITION_HPP | ||
#endif // CRYPTO3_BLUEPRINT_COMPONENTS_PLONK_MNT6_G2_POINT_ADDITION_HPP |