tate_precompute_g2.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_TATE_PRECOMPUTE_G2_HPP
27 #define CRYPTO3_ALGEBRA_PAIRING_EDWARDS_183_TATE_PRECOMPUTE_G2_HPP
28 
31 
32 namespace nil {
33  namespace crypto3 {
34  namespace algebra {
35  namespace pairing {
36 
37  template<std::size_t Version = 183>
38  class edwards_ate_precompute_g1;
39 
40  template<>
41  class edwards_ate_precompute_g1<183> {
42  using curve_type = curves::edwards<183>;
43 
44  typedef detail::types_policy<curve_type> policy_type;
45 
46  using g2_type = typename curve_type::template g2_type<>;
47  using g2_affine_type = typename curve_type::template g2_type<curves::coordinates::affine>;
48 
49  public:
50  using g2_precomputed_type = typename policy_type::tate_g2_precomp;
51 
52  static typename policy_type::tate_g2_precomp process(const typename g2_type::value_type &P) {
53 
54  typename g2_affine_type::value_type Qcopy = Q.to_affine();
55  typename policy_type::tate_g2_precomp result;
56  result.y0 = Qcopy.Y * Qcopy.Z.inversed();
57  result.eta = (Qcopy.Z + Qcopy.Y) * gt::mul_by_non_residue(Qcopy.X).inversed();
58 
59  return result;
60  }
61  };
62  } // namespace pairing
63  } // namespace algebra
64  } // namespace crypto3
65 } // namespace nil
66 #endif // CRYPTO3_ALGEBRA_PAIRING_EDWARDS_183_TATE_PRECOMPUTE_G2_HPP
typename policy_type::tate_g2_precomp g2_precomputed_type
Definition: tate_precompute_g2.hpp:50
static policy_type::tate_g2_precomp process(const typename g2_type::value_type &P)
Definition: tate_precompute_g2.hpp:52
Definition: pair.hpp:31