Botan 2.13.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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 class PointGFp_Base_Point_Precompute final
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,
23 RandomNumberGenerator& rng,
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
42 class PointGFp_Var_Point_Precompute final
43 {
44 public:
45 PointGFp_Var_Point_Precompute(const PointGFp& point,
46 RandomNumberGenerator& rng,
47 std::vector<BigInt>& ws);
48
49 PointGFp mul(const BigInt& k,
50 RandomNumberGenerator& rng,
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 */
64 secure_vector<word> m_T;
65 };
66
67 class PointGFp_Multi_Point_Precompute final
68 {
69 public:
70 PointGFp_Multi_Point_Precompute(const PointGFp& g1,
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
Botan::BigInt
Definition: bigint.h:24
Botan::PointGFp
Definition: point_gfp.h:47
Botan::RandomNumberGenerator
Definition: rng.h:24
Botan::PointGFp_Var_Point_Precompute
Definition: point_mul.h:42
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:28
Botan::PointGFp_Multi_Point_Precompute
Definition: point_mul.h:67
Botan::PointGFp_Base_Point_Precompute::mul
PointGFp mul(const BigInt &k, RandomNumberGenerator &rng, const BigInt &group_order, std::vector< BigInt > &ws) const
Definition: point_mul.cpp:106
Botan::PointGFp_Base_Point_Precompute
Definition: point_mul.h:16
Botan::PointGFp_Base_Point_Precompute::PointGFp_Base_Point_Precompute
PointGFp_Base_Point_Precompute(const PointGFp &base_point, const Modular_Reducer &mod_order)
Definition: point_mul.cpp:50
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:65
m_window_bits
size_t m_window_bits
Definition: pow_mod.cpp:52
Botan
Definition: alg_id.cpp:13
m_p_words
size_t m_p_words
Definition: curve_gfp.cpp:84
Botan::Modular_Reducer
Definition: reducer.h:18
Botan::CurveGFp
Definition: curve_gfp.h:96