Skip to content

Commit

Permalink
Updated and renamed group_order property #133
Browse files Browse the repository at this point in the history
  • Loading branch information
vo-nil committed Feb 26, 2024
1 parent b9706b1 commit 6f8a465
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion include/nil/crypto3/algebra/curves/mnt6.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#ifndef CRYPTO3_ALGEBRA_CURVES_MNT6_HPP
#define CRYPTO3_ALGEBRA_CURVES_MNT6_HPP

#include <nil/crypto3/algebra/curves/detail/mnt4/types.hpp>
#include <nil/crypto3/algebra/curves/detail/mnt6/types.hpp>
#include <nil/crypto3/algebra/curves/detail/mnt6/g1.hpp>
#include <nil/crypto3/algebra/curves/detail/mnt6/g2.hpp>

Expand Down
2 changes: 1 addition & 1 deletion include/nil/crypto3/algebra/fields/detail/element/fp2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ namespace nil {
}

constexpr bool is_square() const {
element_fp2 tmp = this->pow(policy_type::group_order);
element_fp2 tmp = this->pow(policy_type::group_order_minus_one_half);
return (tmp.is_one() || tmp.is_zero()); // maybe can be done more effective
}

Expand Down
2 changes: 1 addition & 1 deletion include/nil/crypto3/algebra/fields/detail/element/fp3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ namespace nil {
}

constexpr bool is_square() const {
element_fp3 tmp = this->pow((policy_type::group_order - 1) / 2);
element_fp3 tmp = this->pow(policy_type::group_order_minus_one_half);
return (tmp.is_one() || tmp.is_zero()); // maybe can be done more effective
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace nil {
0x6AF0E0437FF400B6831E36D6BD17FFE48395DABC2D3435E77F76E17009241C5EE67992F72EC05F4C81084FBEDE3CC09_cppui379,
0x135203E60180A68EE2E9C448D77A2CD91C3DEDD930B1CF60EF396489F61EB45E304466CF3E67FA0AF1EE7B04121BDEA2_cppui381};

constexpr static const extended_integral_type group_order =
constexpr static const extended_integral_type group_order_minus_one_half =
0x1521BD25C61AFE3A5E93C75511792F4F16E48728738235A3372CF249A4F45E82853167E8B6EE5377A98A49984BC77808EB430CE430C2E3D949742D43848D024B35FC8F69F38DBA18B1619C1B1089E7EBE76B58EBB1C1755935500000E38C71C_cppui761;

/*constexpr static const std::array<non_residue_type, 2> Frobenius_coeffs_c1 =
Expand Down Expand Up @@ -121,7 +121,8 @@ namespace nil {
0x00,
0x1ABEF7237D62007BB9B2EDA5AFCB52F9D179F23DBD49B8D1B24CF7C1BF8066791317689172D0F4CB90CF47182B7D7B2_cppui377};

constexpr static const extended_integral_type group_order =
// constexpr static const extended_integral_type group_order_minus_one_half = (pow(base_field_type::modulus, 2)-1)/2;
constexpr static const extended_integral_type group_order_minus_one_half =
0x16983E85DD7FD912B489DD9B0931E25DC5C3ED257749F8FAF38A09EED26AE04E80C57DC833066E00A7389281526B62305555545DB857018C1925CAC31C64EB5E5FDE91AF8E04D256D1347970DEC00399C692A780000008508C00000000000_cppui753;

/*constexpr static const std::array<non_residue_type, 2> Frobenius_coeffs_c1 =
Expand Down Expand Up @@ -165,9 +166,9 @@ namespace nil {
fp2_extension_params<bls12_base_field<377>>::nqr_to_t;

constexpr typename fp2_extension_params<bls12_base_field<381>>::extended_integral_type const
fp2_extension_params<bls12_base_field<381>>::group_order;
fp2_extension_params<bls12_base_field<381>>::group_order_minus_one_half;
constexpr typename fp2_extension_params<bls12_base_field<377>>::extended_integral_type const
fp2_extension_params<bls12_base_field<377>>::group_order;
fp2_extension_params<bls12_base_field<377>>::group_order_minus_one_half;

constexpr std::array<typename fp2_extension_params<bls12_base_field<381>>::integral_type, 2> const
fp2_extension_params<bls12_base_field<381>>::Frobenius_coeffs_c1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ namespace nil {
0xB20DCB5704E326A0DD3ECD4F30515275398A41A4E1DC5D347CFBBEDDA71CF82_cppui252,
0xB1FFEFD8885BF22252522C29527D19F05CFC50E9715370AB0F3A6CA462390C_cppui248};

constexpr static const extended_integral_type group_order =
0x492E25C3B1E5FCE2CCD37BE01A4690E5805C2A88B1BAB031376FD2E1A6359C682344F4ABD09216425280C4E36CB656E5301039684F560809DAA2C5113AEB4D8_cppui507;
constexpr static const extended_integral_type group_order_minus_one_half = (pow(base_field_type::modulus, 2)-1)/2;

/*constexpr static const std::array<non_residue_type, 2> Frobenius_coeffs_c1 =
{non_residue_type(0x00), non_residue_type(0x00)};*/
Expand Down Expand Up @@ -112,7 +111,7 @@ namespace nil {

template<std::size_t Version>
constexpr typename fp2_extension_params<bn128_base_field<Version>>::extended_integral_type const
fp2_extension_params<bn128_base_field<Version>>::group_order;
fp2_extension_params<bn128_base_field<Version>>::group_order_minus_one_half;

template<std::size_t Version>
constexpr std::array<typename fp2_extension_params<bn128_base_field<Version>>::integral_type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace nil {
0x1366271F76AB41CEEEE8C1E5E972F3CEC14A25F18B3F4B93642FAD4972356D977470E0FA674_cppui297,
0x00, 0x00};

constexpr static const extended_integral_type group_order =
constexpr static const extended_integral_type group_order_minus_one_half =
0x1A1E3D618BA643D0F7F10B59BD7DB6981AD661CC756DCF7EC82F4F320CF354C814FAB1F72198E11AAE5A65BFAC8866CDA5F25E91FE3405FB619822AE7756E3F1CBC0B60FBD44114FC23E7CC3932D198CBE6F3DF9DF28E58FF8DBDC80329943BF3F003B81A48CADD598E4CEF600000000_cppui893;

/*constexpr static const std::array<non_residue_type, 3> Frobenius_coeffs_c1 =
Expand Down Expand Up @@ -123,7 +123,7 @@ namespace nil {

template<std::size_t Version>
constexpr typename fp3_extension_params<mnt6_base_field<Version>>::extended_integral_type const
fp3_extension_params<mnt6_base_field<Version>>::group_order;
fp3_extension_params<mnt6_base_field<Version>>::group_order_minus_one_half;

template<std::size_t Version>
constexpr typename fp3_extension_params<mnt6_base_field<Version>>::integral_type const
Expand Down
2 changes: 2 additions & 0 deletions include/nil/crypto3/algebra/fields/params.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#ifndef CRYPTO3_ALGEBRA_FIELDS_PARAMS_HPP
#define CRYPTO3_ALGEBRA_FIELDS_PARAMS_HPP

#include <cstddef>

namespace nil {
namespace crypto3 {
namespace algebra {
Expand Down
2 changes: 1 addition & 1 deletion include/nil/crypto3/algebra/pairing/alt_bn128.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include <nil/crypto3/algebra/curves/babyjubjub.hpp>
#include <nil/crypto3/algebra/curves/alt_bn128.hpp>
#include <nil/crypto3/algebra/pairing/detail/alt_bn128/254/params.hpp>
#include <nil/crypto3/algebra/pairing/detail/alt_bn128/params.hpp>
#include <nil/crypto3/algebra/pairing/forms/short_weierstrass/jacobian_with_a4_0/ate_double_miller_loop.hpp>
#include <nil/crypto3/algebra/pairing/forms/short_weierstrass/jacobian_with_a4_0/ate_miller_loop.hpp>
#include <nil/crypto3/algebra/pairing/forms/short_weierstrass/jacobian_with_a4_0/ate_precompute_g1.hpp>
Expand Down
2 changes: 1 addition & 1 deletion test/curves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <iostream>
#include <type_traits>

#include <boost/test/unit_test.hpp>
#include <boost/test/included/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
#include <boost/test/data/monomorphic.hpp>

Expand Down
2 changes: 1 addition & 1 deletion test/pairing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <vector>
#include <array>

#include <boost/test/unit_test.hpp>
#include <boost/test/included/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
#include <boost/test/data/monomorphic.hpp>

Expand Down

0 comments on commit 6f8a465

Please sign in to comment.