evaluation_domain.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_MATH_EVALUATION_DOMAIN_HPP
27 #define CRYPTO3_MATH_EVALUATION_DOMAIN_HPP
28 
29 #include <vector>
30 
31 #include <nil/crypto3/multiprecision/integer.hpp>
32 
33 namespace nil {
34  namespace crypto3 {
35  namespace math {
36 
40  template<typename FieldType>
42 
43  typedef typename FieldType::value_type value_type;
44 
45  public:
46  typedef FieldType field_type;
47 
48  value_type root;
49  value_type root_inverse;
50  value_type domain;
51  value_type domain_inverse;
52  value_type generator;
53  value_type generator_inverse;
54 
55  std::size_t m;
56  std::size_t log2_size;
57  std::size_t generator_size;
58 
64  evaluation_domain(const std::size_t m) : m(m), log2_size(multiprecision::msb(m)) {};
65 
69  virtual value_type get_domain_element(const std::size_t idx) = 0;
70 
74  virtual void fft(std::vector<value_type> &a) = 0;
75 
79  virtual void inverse_fft(std::vector<value_type> &a) = 0;
80 
90  virtual std::vector<value_type> evaluate_all_lagrange_polynomials(const value_type &t) = 0;
91 
95  virtual value_type compute_vanishing_polynomial(const value_type &t) = 0;
96 
100  virtual void add_poly_z(const value_type &coeff, std::vector<value_type> &H) = 0;
101 
105  virtual void divide_by_z_on_coset(std::vector<value_type> &P) = 0;
106  };
107  } // namespace math
108  } // namespace crypto3
109 } // namespace nil
110 
111 #endif // ALGEBRA_FFT_EVALUATION_DOMAIN_HPP
Definition: evaluation_domain.hpp:41
value_type generator
Definition: evaluation_domain.hpp:52
value_type domain_inverse
Definition: evaluation_domain.hpp:51
FieldType field_type
Definition: evaluation_domain.hpp:46
virtual void divide_by_z_on_coset(std::vector< value_type > &P)=0
value_type domain
Definition: evaluation_domain.hpp:50
virtual value_type get_domain_element(const std::size_t idx)=0
std::size_t generator_size
Definition: evaluation_domain.hpp:57
value_type root_inverse
Definition: evaluation_domain.hpp:49
std::size_t m
Definition: evaluation_domain.hpp:55
virtual void add_poly_z(const value_type &coeff, std::vector< value_type > &H)=0
virtual void fft(std::vector< value_type > &a)=0
virtual std::vector< value_type > evaluate_all_lagrange_polynomials(const value_type &t)=0
std::size_t log2_size
Definition: evaluation_domain.hpp:56
virtual value_type compute_vanishing_polynomial(const value_type &t)=0
evaluation_domain(const std::size_t m)
Definition: evaluation_domain.hpp:64
value_type root
Definition: evaluation_domain.hpp:48
virtual void inverse_fft(std::vector< value_type > &a)=0
value_type generator_inverse
Definition: evaluation_domain.hpp:53
Definition: pair.hpp:31