Botan 2.19.5 Crypto and TLS for C&

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
35 /*
36 * This is a table of T_size * 3*p_word words
37 */
38 std::vector<word> m_W;
39 };
40
41 class PointGFp_Var_Point_Precompute final
42 {
43 public:
44 PointGFp_Var_Point_Precompute(const PointGFp& point,
45 RandomNumberGenerator& rng,
46 std::vector<BigInt>& ws);
47
48 PointGFp mul(const BigInt& k,
49 RandomNumberGenerator& rng,
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 */
63 secure_vector<word> m_T;
64 };
65
66 class PointGFp_Multi_Point_Precompute final
67 {
68 public:
69 PointGFp_Multi_Point_Precompute(const PointGFp& g1,
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
Botan::BigInt
Definition: bigint.h:25
Botan::CurveGFp
Definition: curve_gfp.h:97
Botan::Modular_Reducer
Definition: reducer.h:19
Botan::PointGFp_Base_Point_Precompute
Definition: point_mul.h:17
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:109
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:54
Botan::PointGFp_Multi_Point_Precompute
Definition: point_mul.h:67
Botan::PointGFp_Multi_Point_Precompute::multi_exp
PointGFp multi_exp(const BigInt &k1, const BigInt &k2) const
Definition: point_mul.cpp:394
Botan::PointGFp_Multi_Point_Precompute::PointGFp_Multi_Point_Precompute
PointGFp_Multi_Point_Precompute(const PointGFp &g1, const PointGFp &g2)
Definition: point_mul.cpp:343
Botan::PointGFp_Var_Point_Precompute
Definition: point_mul.h:42
Botan::PointGFp_Var_Point_Precompute::mul
PointGFp mul(const BigInt &k, RandomNumberGenerator &rng, const BigInt &group_order, std::vector< BigInt > &ws) const
Definition: point_mul.cpp:267
Botan::PointGFp_Var_Point_Precompute::PointGFp_Var_Point_Precompute
PointGFp_Var_Point_Precompute(const PointGFp &point, RandomNumberGenerator &rng, std::vector< BigInt > &ws)
Definition: point_mul.cpp:202
Botan::PointGFp
Definition: point_gfp.h:48
Botan::RandomNumberGenerator
Definition: rng.h:26
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:29
Botan
Definition: alg_id.cpp:13
Botan::secure_vector
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65