bls12/377/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_377_SHORT_WEIERSTRASS_PARAMS_HPP
27 #define CRYPTO3_ALGEBRA_CURVES_BLS12_377_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<377, forms::short_weierstrass> {
42 
45 
46  constexpr static const typename bls12_types<377>::integral_type a =
48  0x00);
49  constexpr static const typename bls12_types<377>::integral_type b =
51  0x01);
52  };
53 
54  template<>
55  struct bls12_g1_params<377, forms::short_weierstrass>
56  : public bls12_params<377, 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  0x8848DEFE740A67C8FC6225BF87FF5485951E2CAA9D41BB188282C8BD37CB5CD5481512FFCD394EEAB9B16EB21BE9EF_cppui376),
69  typename field_type::value_type(
70  0x1914A69C5102EFF1F674F5D30AFEEC4BD7FB348CA3E52D96D182AD44FB82305C2FE3D3634A9591AFD82DE55559C8EA6_cppui377)};
71  };
72 
73  template<>
74  struct bls12_g2_params<377, forms::short_weierstrass>
75  : public bls12_params<377, forms::short_weierstrass> {
76 
78 
79  template<typename Coordinates>
81 
82  constexpr static const typename field_type::value_type twist =
83  typename field_type::value_type(field_type::value_type::underlying_type::zero(),
84  field_type::value_type::underlying_type::one());
85  constexpr static const typename field_type::value_type::underlying_type g1_b =
86  typename field_type::value_type::underlying_type(b);
87  constexpr static const typename field_type::value_type b = g1_b * twist.inversed();
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  0xB997FEF930828FE1B9E6A1707B8AA508A3DBFD7FE2246499C709226A0A6FEF49F85B3A375363F4F8F6EA3FBD159F8A_cppui376,
95  0xD6AC33B84947D9845F81A57A136BFA326E915FABC8CD6A57FF133B42D00F62E4E1AF460228CD5184DEAE976FA62596_cppui376),
96  typename field_type::value_type(
97  0x118DD509B2E9A13744A507D515A595DBB7E3B63DF568866473790184BDF83636C94DF2B7A962CB2AF4337F07CB7E622_cppui377,
98  0x185067C6CA76D992F064A432BD9F9BE832B0CAC2D824D0518F77D39E76C3E146AFB825F2092218D038867D7F337A010_cppui377)};
99  };
100 
101  constexpr
103  constexpr
105 
106  constexpr std::array<
107  typename bls12_g1_params<377, forms::short_weierstrass>::field_type::value_type,
109  constexpr std::array<
110  typename bls12_g1_params<377, forms::short_weierstrass>::field_type::value_type,
112 
113  constexpr std::array<
114  typename bls12_g2_params<377, forms::short_weierstrass>::field_type::value_type,
116  constexpr std::array<
117  typename bls12_g2_params<377, forms::short_weierstrass>::field_type::value_type,
119 
120  } // namespace detail
121  } // namespace curves
122  } // namespace algebra
123  } // namespace crypto3
124 } // namespace nil
125 
126 #endif // CRYPTO3_ALGEBRA_CURVES_BLS12_377_SHORT_WEIERSTRASS_PARAMS_HPP
Definition: pair.hpp:31
constexpr static const std::array< typename field_type::value_type, 2 > zero_fill
Definition: bls12/377/short_weierstrass_params.hpp:63
constexpr static const std::array< typename field_type::value_type, 2 > one_fill
Definition: bls12/377/short_weierstrass_params.hpp:66
bls12_types< 377 >::g1_type< forms::short_weierstrass, Coordinates > group_type
Definition: bls12/377/short_weierstrass_params.hpp:61
typename bls12_types< 377 >::g1_field_type field_type
Definition: bls12/377/short_weierstrass_params.hpp:58
Definition: curves/detail/bls12/types.hpp:51
constexpr static const std::array< typename field_type::value_type, 2 > zero_fill
Definition: bls12/377/short_weierstrass_params.hpp:89
typename bls12_types< 377 >::g2_field_type field_type
Definition: bls12/377/short_weierstrass_params.hpp:77
bls12_types< 377 >::g2_type< forms::short_weierstrass, Coordinates > group_type
Definition: bls12/377/short_weierstrass_params.hpp:80
constexpr static const std::array< typename field_type::value_type, 2 > one_fill
Definition: bls12/377/short_weierstrass_params.hpp:92
Definition: curves/detail/bls12/types.hpp:54
constexpr static const bls12_types< 377 >::integral_type a
coefficient of short Weierstrass curve $y^2=x^3+a*x+b$
Definition: bls12/377/short_weierstrass_params.hpp:46
constexpr static const bls12_types< 377 >::integral_type b
coefficient of short Weierstrass curve $y^2=x^3+a*x+b$
Definition: bls12/377/short_weierstrass_params.hpp:49
typename bls12_types< 377 >::scalar_field_type scalar_field_type
Definition: bls12/377/short_weierstrass_params.hpp:44
typename bls12_types< 377 >::base_field_type base_field_type
Definition: bls12/377/short_weierstrass_params.hpp:43
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