Skip to content

Commit

Permalink
work in progress #147
Browse files Browse the repository at this point in the history
  • Loading branch information
vo-nil committed Mar 10, 2024
1 parent 232df37 commit 7ffb5fc
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 5 deletions.
1 change: 1 addition & 0 deletions include/nil/crypto3/algebra/curves/alt_bn128.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define CRYPTO3_ALGEBRA_CURVES_ALT_BN128_HPP

#include <nil/crypto3/algebra/curves/detail/alt_bn128/types.hpp>

#include <nil/crypto3/algebra/curves/detail/alt_bn128/g1.hpp>
#include <nil/crypto3/algebra/curves/detail/alt_bn128/g2.hpp>

Expand Down
9 changes: 6 additions & 3 deletions include/nil/crypto3/algebra/fields/alt_bn128/base_field.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ namespace nil {

constexpr static const integral_type modulus =
0x30644E72E131A029B85045B68181585D97816A916871CA8D3C208C16D87CFD47_cppui254;


// constexpr static const integral_type group_order_minus_one_half =
// (modulus - 1) / 2;
/*
constexpr static const integral_type group_order_minus_one_half =
0x183227397098D014DC2822DB40C0AC2ECBC0B548B438E5469E10460B6C3E7EA3_cppui254;

*/
typedef typename policy_type::modular_backend modular_backend;
constexpr static const modular_params_type modulus_params = modulus;
typedef nil::crypto3::multiprecision::number<
Expand All @@ -84,7 +87,7 @@ namespace nil {

constexpr typename alt_bn128_base_field<254>::integral_type const alt_bn128_base_field<254>::modulus;

constexpr typename alt_bn128_base_field<254>::integral_type const alt_bn128_base_field<254>::group_order_minus_one_half;
// constexpr typename alt_bn128_base_field<254>::integral_type const alt_bn128_base_field<254>::group_order_minus_one_half;

constexpr typename alt_bn128_base_field<254>::modular_params_type const
alt_bn128_base_field<254>::modulus_params;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace nil {
constexpr static const std::size_t integral_type_max_bits =
curve_type::base_field_type::modulus_bits;

constexpr static const integral_type ate_loop_count = 0x19D797039BE763BA9_cppui254;
constexpr static const integral_type ate_loop_count = 0x19D797039BE763BA8_cppui254;
constexpr static const bool ate_is_loop_count_neg = false;
constexpr static const extended_integral_type final_exponent = extended_integral_type(
0x2F4B6DC97020FDDADF107D20BC842D43BF6369B1FF6A1C71015F3F7BE2E1E30A73BB94FEC0DAF15466B2383A5D3EC3D15AD524D8F70C54EFEE1BD8C3B21377E563A09A1B705887E72ECEADDEA3790364A61F676BAAF977870E88D5C6C8FEF0781361E443AE77F5B63A2A2264487F2940A8B1DDB3D15062CD0FB2015DFC6668449AED3CC48A82D0D602D268C7DAAB6A41294C0CC4EBE5664568DFC50E1648A45A4A1E3A5195846A3ED011A337A02088EC80E0EBAE8755CFE107ACF3AAFB40494E406F804216BB10CF430B0F37856B42DB8DC5514724EE93DFB10826F0DD4A0364B9580291D2CD65664814FDE37CA80BB4EA44EACC5E641BBADF423F9A2CBF813B8D145DA90029BAEE7DDADDA71C7F3811C4105262945BBA1668C3BE69A3C230974D83561841D766F9C9D570BB7FBE04C7E8A6C3C760C0DE81DEF35692DA361102B6B9B2B918837FA97896E84ABB40A4EFB7E54523A486964B64CA86F120_cppui2790);
Expand Down
44 changes: 43 additions & 1 deletion test/pairing_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,46 @@ void check_pairing_operations() {
std::cerr << "}";
}

template<typename CurveType>
void check_curve() {
using curve_type = CurveType;
using scalar_field_type = typename curve_type::scalar_field_type;
using g1_type = typename curve_type::template g1_type<>;
using g2_type = typename curve_type::template g2_type<>;
using gt_type = typename curve_type::gt_type;
using g1_field_value_type = typename g1_type::field_type::value_type;
using g2_field_value_type = typename g2_type::field_type::value_type;

typename scalar_field_type::value_type
c1,c2;

typename g1_type::value_type G1, A1, A2;
typename g1_type::value_type p1 = {
0x22c26a3c19d56fc8790485554be5dc4351961a5162c3634965dc8ae56701157e_cppui254,
0x1e3305b98bf381650491b7b63559d20d662b70f1616e680a19170715b59a3426_cppui254,
0x2dadec13affe7e4ad00a4c896773b96ce87fbcb232b8660721adc1f266defa45_cppui254,
};
typename g1_type::value_type p2 = {
0x148a1f438a4cd0d807549cb7f9ec9f41dba3d8b14a6b0f2489d9b9f626d6fd31_cppui254,
0x3cc907ef65b0eff91d027e4771e9116a0b125325627b6bdf55037702220b1b2_cppui254,
0x1242df09f53bda3a3bfb5fb2054817c6cbb32a7217556a6c831113f4d3fee54c_cppui254,
};
G1 = g1_type::value_type::one();
// G2 = g2_type::value_type::one();

c1 = 345751109;
c2 = 270382749;

A1 = G1*c1;
A2 = G1*c2;

print_curve_group_element(std::cout, p1); std::cout << std::endl;
print_curve_group_element(std::cout, p2); std::cout << std::endl;

print_curve_group_element_affine(std::cout, p1.to_affine()); std::cout << std::endl;
print_curve_group_element_affine(std::cout, p2.to_affine()); std::cout << std::endl;

}

BOOST_AUTO_TEST_SUITE(pairing_debug_tests)
BOOST_AUTO_TEST_CASE(pairing_operation_test_atl_bn128_254) {
Expand All @@ -745,7 +785,9 @@ BOOST_AUTO_TEST_CASE(pairing_operation_test_atl_bn128_254) {
//using curve_type = typename curves::mnt6<298>;
//using curve_type = typename curves::bls12<381>;

check_pairing_operations<curve_type>();
check_curve<curve_type>();

// check_pairing_operations<curve_type>();
}

/*
Expand Down

0 comments on commit 7ffb5fc

Please sign in to comment.