#include <bigint.hpp>
Definition at line 10 of file bigint.hpp.
◆ bigint() [1/7]
fc::bigint::bigint |
( |
const std::vector< char > & | bige | ) |
|
Definition at line 15 of file bigint.cpp.
15 {
16 n = BN_bin2bn( (const unsigned char*)bige.data(), bige.size(), NULL );
18 }
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
◆ bigint() [2/7]
fc::bigint::bigint |
( |
const char * | bige, |
|
|
uint32_t | l ) |
Definition at line 11 of file bigint.cpp.
11 {
12 n = BN_bin2bn( (
const unsigned char*)bige,
l, NULL );
14 }
◆ bigint() [3/7]
Definition at line 32 of file bigint.cpp.
33 {
35 n = BN_bin2bn((const unsigned char*)&big_endian_value, sizeof(big_endian_value), NULL);
36 }
unsigned __int64 uint64_t
◆ bigint() [4/7]
◆ bigint() [5/7]
fc::bigint::bigint |
( |
const bigint & | c | ) |
|
Definition at line 38 of file bigint.cpp.
38 {
39 n = BN_dup( c.n );
40 }
◆ bigint() [6/7]
fc::bigint::bigint |
( |
bigint && | c | ) |
|
Definition at line 42 of file bigint.cpp.
42 {
43 n = b.n;
44 b.n = 0;
45 }
◆ bigint() [7/7]
fc::bigint::bigint |
( |
BIGNUM * | n | ) |
|
|
explicit |
Definition at line 19 of file bigint.cpp.
20 {
21 n = BN_dup(in);
22 }
◆ ~bigint()
Definition at line 47 of file bigint.cpp.
47 {
48 if(n!=0) BN_free(n);
49 }
◆ dup()
BIGNUM * fc::bigint::dup |
( |
| ) |
const |
Definition at line 27 of file bigint.cpp.
28 {
29 return BN_dup( n );
30 }
◆ exp()
Definition at line 180 of file bigint.cpp.
181 {
182 BN_CTX* ctx = BN_CTX_new();
184 BN_exp( tmp.n, n,
a.n, ctx );
185 BN_CTX_free(ctx);
186 return tmp;
187 }
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
◆ get()
BIGNUM * fc::bigint::get |
( |
| ) |
const |
|
inline |
◆ is_negative()
bool fc::bigint::is_negative |
( |
| ) |
const |
Definition at line 51 of file bigint.cpp.
51{ return BN_is_negative(n); }
◆ log2()
Definition at line 62 of file bigint.cpp.
62{ return BN_num_bits(n); }
◆ operator bool()
fc::bigint::operator bool |
( |
| ) |
const |
|
explicit |
Definition at line 78 of file bigint.cpp.
79 {
80 return !BN_is_zero( n );
81 }
◆ operator fc::string()
Definition at line 200 of file bigint.cpp.
200 {
201 return BN_bn2dec(n);
202 }
◆ operator std::vector< char >()
fc::bigint::operator std::vector< char > |
( |
| ) |
const |
Definition at line 204 of file bigint.cpp.
204 {
205 std::vector<char> to(BN_num_bytes(n));
206 BN_bn2bin(n,(unsigned char*)to.data());
207 return to;
208 }
◆ operator!=()
bool fc::bigint::operator!= |
( |
const bigint & | c | ) |
const |
Definition at line 75 of file bigint.cpp.
75 {
76 return BN_cmp( n, c.n ) != 0;
77 }
◆ operator%()
Definition at line 136 of file bigint.cpp.
136 {
137 BN_CTX* ctx = BN_CTX_new();
139 BN_mod( tmp.n, n,
a.n, ctx );
140 BN_CTX_free(ctx);
141 return tmp;
142 }
◆ operator*()
Definition at line 122 of file bigint.cpp.
122 {
123 BN_CTX* ctx = BN_CTX_new();
125 BN_mul( tmp.n, n,
a.n, ctx );
126 BN_CTX_free(ctx);
127 return tmp;
128 }
◆ operator*=()
Definition at line 152 of file bigint.cpp.
152 {
153 auto tmp = *
this *
a;
154 *this = std::move(tmp);
155 return *this;
156 }
◆ operator+()
Definition at line 103 of file bigint.cpp.
103 {
105 BN_add( tmp.n, n,
a.n );
106 return tmp;
107 }
◆ operator++() [1/2]
bigint & fc::bigint::operator++ |
( |
| ) |
|
◆ operator++() [2/2]
bigint fc::bigint::operator++ |
( |
int | | ) |
|
◆ operator+=()
Definition at line 108 of file bigint.cpp.
108 {
110 BN_add( tmp.n, n,
a.n );
112 return *this;
113 }
void swap(picojson::value &x, picojson::value &y)
◆ operator-()
Definition at line 175 of file bigint.cpp.
175 {
177 BN_sub( tmp.n, n,
a.n );
178 return tmp;
179 }
◆ operator--() [1/2]
bigint & fc::bigint::operator-- |
( |
| ) |
|
Definition at line 98 of file bigint.cpp.
99 {
100 return *
this = *
this -
bigint(1);
101 }
◆ operator--() [2/2]
bigint fc::bigint::operator-- |
( |
int | | ) |
|
◆ operator-=()
Definition at line 114 of file bigint.cpp.
114 {
116 BN_sub( tmp.n, n,
a.n );
118 return *this;
119 }
◆ operator/()
Definition at line 129 of file bigint.cpp.
129 {
130 BN_CTX* ctx = BN_CTX_new();
132 BN_div( tmp.n, NULL, n,
a.n, ctx );
133 BN_CTX_free(ctx);
134 return tmp;
135 }
◆ operator/=()
Definition at line 144 of file bigint.cpp.
144 {
145 BN_CTX* ctx = BN_CTX_new();
147 BN_div( tmp.n, NULL, n,
a.n, ctx );
149 BN_CTX_free(ctx);
150 return tmp;
151 }
◆ operator<()
bool fc::bigint::operator< |
( |
const bigint & | c | ) |
const |
Definition at line 63 of file bigint.cpp.
63 {
64 return BN_cmp( n, c.n ) < 0;
65 }
◆ operator<<=()
Definition at line 165 of file bigint.cpp.
166 {
170 BN_lshift( tmp.n, n, i );
172 return *this;
173 }
◆ operator=() [1/2]
Definition at line 190 of file bigint.cpp.
190 {
192 return *this;
193 }
◆ operator=() [2/2]
Definition at line 194 of file bigint.cpp.
194 {
196 return *this;
198 return *this;
199 }
◆ operator==()
bool fc::bigint::operator== |
( |
const bigint & | c | ) |
const |
Definition at line 72 of file bigint.cpp.
72 {
73 return BN_cmp( n, c.n ) == 0;
74 }
◆ operator>()
bool fc::bigint::operator> |
( |
const bigint & | c | ) |
const |
Definition at line 66 of file bigint.cpp.
66 {
67 return BN_cmp( n, c.n ) > 0;
68 }
◆ operator>=()
bool fc::bigint::operator>= |
( |
const bigint & | c | ) |
const |
Definition at line 69 of file bigint.cpp.
69 {
70 return BN_cmp( n, c.n ) >= 0;
71 }
◆ operator>>=()
Definition at line 157 of file bigint.cpp.
158 {
160 BN_rshift( tmp.n, n, i );
162 return *this;
163 }
◆ random()
◆ to_int64()
int64_t fc::bigint::to_int64 |
( |
| ) |
const |
Definition at line 53 of file bigint.cpp.
54 {
56 size_t size = BN_num_bytes(n);
58 BN_bn2bin(n, (
unsigned char*)&abs_value + (
sizeof(
uint64_t) - size));
59 return BN_is_negative(n) ? -(
int64_t)bswap_64(abs_value) : bswap_64(abs_value);
60 }
The documentation for this class was generated from the following files: