0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-15 11:36:00 -05:00
bitcoin-bitcoin-core/num_openssl.h

51 lines
1.4 KiB
C
Raw Normal View History

2013-03-10 21:25:19 +01:00
#ifndef _SECP256K1_NUM_OPENSSL_
#define _SECP256K1_NUM_OPENSSL_
#include <string>
#include <openssl/bn.h>
2013-03-10 21:25:19 +01:00
namespace secp256k1 {
class Number {
private:
BIGNUM b;
2013-03-16 15:51:55 +01:00
Number(const Number &x);
2013-03-16 15:51:55 +01:00
operator const BIGNUM*() const;
operator BIGNUM*();
2013-03-10 21:25:19 +01:00
public:
2013-03-16 15:51:55 +01:00
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;
2013-03-18 02:41:01 +01:00
bool CheckBit(int pos) const;
2013-03-16 15:51:55 +01:00
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;
2013-03-10 21:25:19 +01:00
};
}
#endif