Botan  2.11.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 
16 static const size_t PointGFp_SCALAR_BLINDING_BITS = 80;
17 
19  {
20  public:
21  PointGFp_Base_Point_Precompute(const PointGFp& base_point,
22  const Modular_Reducer& mod_order);
23 
24  PointGFp mul(const BigInt& k,
25  RandomNumberGenerator& rng,
26  const BigInt& group_order,
27  std::vector<BigInt>& ws) const;
28  private:
29  const PointGFp& m_base_point;
30  const Modular_Reducer& m_mod_order;
31 
32  enum { WINDOW_BITS = 3 };
33  enum { WINDOW_SIZE = (1 << WINDOW_BITS) - 1 };
34 
35  const size_t m_p_words;
36  const size_t m_T_size;
37 
38  /*
39  * This is a table of T_size * 3*p_word words
40  */
41  std::vector<word> m_W;
42  };
43 
45  {
46  public:
47  PointGFp_Var_Point_Precompute(const PointGFp& point,
48  RandomNumberGenerator& rng,
49  std::vector<BigInt>& ws);
50 
51  PointGFp mul(const BigInt& k,
52  RandomNumberGenerator& rng,
53  const BigInt& group_order,
54  std::vector<BigInt>& ws) const;
55  private:
56  const CurveGFp m_curve;
57  const size_t m_p_words;
58  const size_t m_window_bits;
59 
60  /*
61  * Table of 2^window_bits * 3*2*p_word words
62  * Kept in locked vector since the base point might be sensitive
63  * (normally isn't in most protocols but hard to say anything
64  * categorically.)
65  */
67  };
68 
70  {
71  public:
72  PointGFp_Multi_Point_Precompute(const PointGFp& g1,
73  const PointGFp& g2);
74 
75  /*
76  * Return (g1*k1 + g2*k2)
77  * Not constant time, intended to use with public inputs
78  */
79  PointGFp multi_exp(const BigInt& k1,
80  const BigInt& k2) const;
81  private:
82  std::vector<PointGFp> m_M;
83  };
84 
85 }
86 
87 #endif
bool RandomNumberGenerator & rng
Definition: numthry.h:176
PointGFp multi_exp(const BigInt &k1, const BigInt &k2) const
Definition: point_mul.cpp:373
PointGFp_Multi_Point_Precompute(const PointGFp &g1, const PointGFp &g2)
Definition: point_mul.cpp:334
secure_vector< word > & ws
Definition: curve_nistp.h:24
int(* final)(unsigned char *, CTX *)
PointGFp_Base_Point_Precompute(const PointGFp &base_point, const Modular_Reducer &mod_order)
Definition: point_mul.cpp:44
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:100
const PointGFp & point
Definition: point_gfp.h:339
PointGFp mul(const BigInt &k, RandomNumberGenerator &rng, const BigInt &group_order, std::vector< BigInt > &ws) const
Definition: point_mul.cpp:258
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:193