Botan  2.19.1
Crypto and TLS for C++11
point_mul.h
Go to the documentation of this file.
1 /*
2 * (C) 2018 Jack Lloyd
3 *
4 * Botan is released under the Simplified BSD License (see license.txt)
5 */
6 
7 #ifndef BOTAN_POINT_MUL_H_
8 #define BOTAN_POINT_MUL_H_
9 
10 #include <botan/point_gfp.h>
11 
12 namespace Botan {
13 
14 class Modular_Reducer;
15 
17  {
18  public:
19  PointGFp_Base_Point_Precompute(const PointGFp& base_point,
20  const Modular_Reducer& mod_order);
21 
22  PointGFp mul(const BigInt& k,
24  const BigInt& group_order,
25  std::vector<BigInt>& ws) const;
26  private:
27  const PointGFp& m_base_point;
28  const Modular_Reducer& m_mod_order;
29 
30  enum { WINDOW_BITS = 3 };
31  enum { WINDOW_SIZE = (1 << WINDOW_BITS) - 1 };
32 
33  const size_t m_p_words;
34 
35  /*
36  * This is a table of T_size * 3*p_word words
37  */
38  std::vector<word> m_W;
39  };
40 
42  {
43  public:
46  std::vector<BigInt>& ws);
47 
48  PointGFp mul(const BigInt& k,
50  const BigInt& group_order,
51  std::vector<BigInt>& ws) const;
52  private:
53  const CurveGFp m_curve;
54  const size_t m_p_words;
55  const size_t m_window_bits;
56 
57  /*
58  * Table of 2^window_bits * 3*2*p_word words
59  * Kept in locked vector since the base point might be sensitive
60  * (normally isn't in most protocols but hard to say anything
61  * categorically.)
62  */
64  };
65 
67  {
68  public:
70  const PointGFp& g2);
71 
72  /*
73  * Return (g1*k1 + g2*k2)
74  * Not constant time, intended to use with public inputs
75  */
76  PointGFp multi_exp(const BigInt& k1,
77  const BigInt& k2) const;
78  private:
79  std::vector<PointGFp> m_M;
80  bool m_no_infinity;
81  };
82 
83 }
84 
85 #endif
int(* final)(unsigned char *, CTX *)
PointGFp mul(const BigInt &k, RandomNumberGenerator &rng, const BigInt &group_order, std::vector< BigInt > &ws) const
Definition: point_mul.cpp:109
PointGFp_Base_Point_Precompute(const PointGFp &base_point, const Modular_Reducer &mod_order)
Definition: point_mul.cpp:54
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:65
size_t m_window_bits
Definition: pow_mod.cpp:52
Definition: alg_id.cpp:13
size_t m_p_words
Definition: curve_gfp.cpp:84