bls12/381/short_weierstrass_params.hpp
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2020-2021 Mikhail Komarov <nemo@nil.foundation>
3 // Copyright (c) 2020-2021 Nikita Kaskov <nbering@nil.foundation>
4 //
5 // MIT License
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a copy
8 // of this software and associated documentation files (the "Software"), to deal
9 // in the Software without restriction, including without limitation the rights
10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 // copies of the Software, and to permit persons to whom the Software is
12 // furnished to do so, subject to the following conditions:
13 //
14 // The above copyright notice and this permission notice shall be included in all
15 // copies or substantial portions of the Software.
16 //
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 // SOFTWARE.
24 //---------------------------------------------------------------------------//
25 
26 #ifndef CRYPTO3_ALGEBRA_CURVES_BLS12_381_SHORT_WEIERSTRASS_PARAMS_HPP
27 #define CRYPTO3_ALGEBRA_CURVES_BLS12_381_SHORT_WEIERSTRASS_PARAMS_HPP
28 
31 
33 
34 namespace nil {
35  namespace crypto3 {
36  namespace algebra {
37  namespace curves {
38  namespace detail {
39 
40  template<>
41  struct bls12_params<381, forms::short_weierstrass> {
42 
45 
46  constexpr static const typename bls12_types<381>::integral_type a =
48  0x00);
49  constexpr static const typename bls12_types<381>::integral_type b =
51  0x04);
52  };
53 
54  template<>
55  struct bls12_g1_params<381, forms::short_weierstrass>
56  : public bls12_params<381, forms::short_weierstrass> {
57 
59 
60  template<typename Coordinates>
62 
63  constexpr static const std::array<typename field_type::value_type, 2> zero_fill = {
64  field_type::value_type::zero(), field_type::value_type::one()};
65 
66  constexpr static const std::array<typename field_type::value_type, 2> one_fill = {
67  typename field_type::value_type(
68  0x17F1D3A73197D7942695638C4FA9AC0FC3688C4F9774B905A14E3A3F171BAC586C55E83FF97A1AEFFB3AF00ADB22C6BB_cppui381),
69  typename field_type::value_type(
70  0x8B3F481E3AAA0F1A09E30ED741D8AE4FCF5E095D5D00AF600DB18CB2C04B3EDD03CC744A2888AE40CAA232946C5E7E1_cppui380)};
71  };
72 
73  template<>
74  struct bls12_g2_params<381, forms::short_weierstrass>
75  : public bls12_params<381, forms::short_weierstrass> {
76 
78 
79  constexpr static const typename field_type::value_type twist =
80  typename field_type::value_type(field_type::value_type::underlying_type::one(),
81  field_type::value_type::underlying_type::one());
82  constexpr static const typename field_type::value_type::underlying_type g1_b =
83  typename field_type::value_type::underlying_type(b);
84  constexpr static const typename field_type::value_type b = g1_b * twist;
85 
86  template<typename Coordinates>
88 
89  constexpr static const std::array<typename field_type::value_type, 2> zero_fill = {
90  field_type::value_type::zero(), field_type::value_type::one()};
91 
92  constexpr static const std::array<typename field_type::value_type, 2> one_fill = {
93  typename field_type::value_type(
94  0x24AA2B2F08F0A91260805272DC51051C6E47AD4FA403B02B4510B647AE3D1770BAC0326A805BBEFD48056C8C121BDB8_cppui378,
95  0x13E02B6052719F607DACD3A088274F65596BD0D09920B61AB5DA61BBDC7F5049334CF11213945D57E5AC7D055D042B7E_cppui381),
96  typename field_type::value_type(
97  0xCE5D527727D6E118CC9CDC6DA2E351AADFD9BAA8CBDD3A76D429A695160D12C923AC9CC3BACA289E193548608B82801_cppui380,
98  0x606C4A02EA734CC32ACD2B02BC28B99CB3E287E85A763AF267492AB572E99AB3F370D275CEC1DA1AAA9075FF05F79BE_cppui379)};
99  };
100 
101  constexpr
103  constexpr
105 
106  constexpr typename bls12_g2_params<381, forms::short_weierstrass>::field_type::value_type const
108 
109  constexpr std::array<
110  typename bls12_g1_params<381, forms::short_weierstrass>::field_type::value_type,
112  constexpr std::array<
113  typename bls12_g1_params<381, forms::short_weierstrass>::field_type::value_type,
115 
116  constexpr std::array<
117  typename bls12_g2_params<381, forms::short_weierstrass>::field_type::value_type,
119  constexpr std::array<
120  typename bls12_g2_params<381, forms::short_weierstrass>::field_type::value_type,
122 
123  } // namespace detail
124  } // namespace curves
125  } // namespace algebra
126  } // namespace crypto3
127 } // namespace nil
128 
129 #endif // CRYPTO3_ALGEBRA_CURVES_BLS12_381_SHORT_WEIERSTRASS_PARAMS_HPP
Definition: pair.hpp:31
constexpr static const std::array< typename field_type::value_type, 2 > zero_fill
Definition: bls12/381/short_weierstrass_params.hpp:63
typename bls12_types< 381 >::g1_field_type field_type
Definition: bls12/381/short_weierstrass_params.hpp:58
bls12_types< 381 >::g1_type< forms::short_weierstrass, Coordinates > group_type
Definition: bls12/381/short_weierstrass_params.hpp:61
constexpr static const std::array< typename field_type::value_type, 2 > one_fill
Definition: bls12/381/short_weierstrass_params.hpp:66
Definition: curves/detail/bls12/types.hpp:51
typename bls12_types< 381 >::g2_field_type field_type
Definition: bls12/381/short_weierstrass_params.hpp:77
constexpr static const std::array< typename field_type::value_type, 2 > one_fill
Definition: bls12/381/short_weierstrass_params.hpp:92
bls12_types< 381 >::g2_type< forms::short_weierstrass, Coordinates > group_type
Definition: bls12/381/short_weierstrass_params.hpp:87
constexpr static const std::array< typename field_type::value_type, 2 > zero_fill
Definition: bls12/381/short_weierstrass_params.hpp:89
constexpr static const field_type::value_type b
Definition: bls12/381/short_weierstrass_params.hpp:84
Definition: curves/detail/bls12/types.hpp:54
typename bls12_types< 381 >::base_field_type base_field_type
Definition: bls12/381/short_weierstrass_params.hpp:43
constexpr static const bls12_types< 381 >::integral_type a
coefficient of short Weierstrass curve $y^2=x^3+a*x+b$
Definition: bls12/381/short_weierstrass_params.hpp:46
constexpr static const bls12_types< 381 >::integral_type b
coefficient of short Weierstrass curve $y^2=x^3+a*x+b$
Definition: bls12/381/short_weierstrass_params.hpp:49
typename bls12_types< 381 >::scalar_field_type scalar_field_type
Definition: bls12/381/short_weierstrass_params.hpp:44
Definition: curves/detail/bls12/types.hpp:48
A struct representing details about base and scalar fields.
Definition: curves/detail/bls12/types.hpp:61
typename base_field_type::integral_type integral_type
Definition: curves/detail/bls12/types.hpp:69
Definition: forms.hpp:34