-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathnum_openssl.h
50 lines (44 loc) · 1.36 KB
/
num_openssl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef _SECP256K1_NUM_OPENSSL_
#define _SECP256K1_NUM_OPENSSL_
#include <string>
#include <openssl/bn.h>
namespace secp256k1 {
class Number {
private:
BIGNUM b;
Number(const Number &x);
operator const BIGNUM*() const;
operator BIGNUM*();
public:
Number();
~Number();
Number(const unsigned char *bin, int len);
void SetNumber(const Number &x);
Number &operator=(const Number &x);
void SetBytes(const unsigned char *bin, int len);
void GetBytes(unsigned char *bin, int len);
void SetInt(int x);
void SetModInverse(const Number &x, const Number &m);
void SetModMul(const Number &a, const Number &b, const Number &m);
void SetAdd(const Number &a1, const Number &a2);
void SetSub(const Number &a1, const Number &a2);
void SetMult(const Number &a1, const Number &a2);
void SetDiv(const Number &a1, const Number &a2);
void SetMod(const Number &a, const Number &m);
int Compare(const Number &a) const;
int GetBits() const;
int ShiftLowBits(int bits);
bool IsZero() const;
bool IsOdd() const;
bool IsNeg() const;
bool CheckBit(int pos) const;
void Negate();
void Shift1();
void Inc();
void SetHex(const std::string &str);
void SetPseudoRand(const Number &max);
void SplitInto(int bits, Number &low, Number &high) const;
std::string ToString() const;
};
}
#endif