Botan  2.13.0
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  const size_t m_T_size;
35 
36  /*
37  * This is a table of T_size * 3*p_word words
38  */
39  std::vector<word> m_W;
40  };
41 
43  {
44  public:
47  std::vector<BigInt>& ws);
48 
49  PointGFp mul(const BigInt& k,
51  const BigInt& group_order,
52  std::vector<BigInt>& ws) const;
53  private:
54  const CurveGFp m_curve;
55  const size_t m_p_words;
56  const size_t m_window_bits;
57 
58  /*
59  * Table of 2^window_bits * 3*2*p_word words
60  * Kept in locked vector since the base point might be sensitive
61  * (normally isn't in most protocols but hard to say anything
62  * categorically.)
63  */
65  };
66 
68  {
69  public:
71  const PointGFp& g2);
72 
73  /*
74  * Return (g1*k1 + g2*k2)
75  * Not constant time, intended to use with public inputs
76  */
77  PointGFp multi_exp(const BigInt& k1,
78  const BigInt& k2) const;
79  private:
80  std::vector<PointGFp> m_M;
81  };
82 
83 }
84 
85 #endif
PointGFp multi_exp(const BigInt &k1, const BigInt &k2) const
Definition: point_mul.cpp:379
PointGFp_Multi_Point_Precompute(const PointGFp &g1, const PointGFp &g2)
Definition: point_mul.cpp:340
int(* final)(unsigned char *, CTX *)
PointGFp_Base_Point_Precompute(const PointGFp &base_point, const Modular_Reducer &mod_order)
Definition: point_mul.cpp:50
Definition: alg_id.cpp:13
PointGFp mul(const BigInt &k, RandomNumberGenerator &rng, const BigInt &group_order, std::vector< BigInt > &ws) const
Definition: point_mul.cpp:106
PointGFp mul(const BigInt &k, RandomNumberGenerator &rng, const BigInt &group_order, std::vector< BigInt > &ws) const
Definition: point_mul.cpp:264
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65
PointGFp_Var_Point_Precompute(const PointGFp &point, RandomNumberGenerator &rng, std::vector< BigInt > &ws)
Definition: point_mul.cpp:199