edwards/183/ate_precompute_g1.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_PAIRING_EDWARDS_183_ATE_PRECOMPUTE_G1_HPP
27 #define CRYPTO3_ALGEBRA_PAIRING_EDWARDS_183_ATE_PRECOMPUTE_G1_HPP
28 
31 
32 namespace nil {
33  namespace crypto3 {
34  namespace algebra {
35  namespace pairing {
36 
37  template<std::size_t Version = 183>
39 
40  template<>
43 
45 
46  using g1_type = typename curve_type::template g1_type<>;
47  using g1_affine_type = typename curve_type::template g1_type<curves::coordinates::affine>;
48 
49  public:
50  using g1_precomputed_type = typename policy_type::ate_g1_precomputed_type;
51 
52  static typename policy_type::ate_g1_precomputed_type
53  process(const typename g1_type::value_type &P) {
54 
55  typename g1_affine_type::value_type Pcopy = P.to_affine();
56  typename policy_type::ate_g1_precomputed_type result;
57  result.P_XY = Pcopy.X * Pcopy.Y;
58  result.P_XZ = Pcopy.X; // P.X * P.Z but P.Z = 1
59  result.P_ZZplusYZ =
60  (g1_type::field_type::value_type::one() + Pcopy.Y); // (P.Z + P.Y) * P.Z but P.Z =
61 
62  return result;
63  }
64  };
65  } // namespace pairing
66  } // namespace algebra
67  } // namespace crypto3
68 } // namespace nil
69 #endif // CRYPTO3_ALGEBRA_PAIRING_EDWARDS_183_ATE_PRECOMPUTE_G1_HPP
Definition: pairing/detail/edwards/183/types.hpp:38
static policy_type::ate_g1_precomputed_type process(const typename g1_type::value_type &P)
Definition: edwards/183/ate_precompute_g1.hpp:53
typename policy_type::ate_g1_precomputed_type g1_precomputed_type
Definition: edwards/183/ate_precompute_g1.hpp:50
Definition: edwards/183/ate_precompute_g1.hpp:38
Definition: pair.hpp:31
A struct representing a Edwards curve, providing 128 bits of security.
Definition: curves/edwards.hpp:51