Master Core  v0.0.9 - 2abfd2849db8ba7a83957c64eb976b406713c123
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
bignum.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2013 The Bitcoin developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_BIGNUM_H
7 #define BITCOIN_BIGNUM_H
8 
9 #include "serialize.h"
10 #include "uint256.h"
11 #include "version.h"
12 
13 #include <stdexcept>
14 #include <stdint.h>
15 #include <string>
16 #include <vector>
17 
18 #include <openssl/bn.h>
19 
21 class bignum_error : public std::runtime_error
22 {
23 public:
24  explicit bignum_error(const std::string& str) : std::runtime_error(str) {}
25 };
26 
27 
30 {
31 protected:
32  BN_CTX* pctx;
33  BN_CTX* operator=(BN_CTX* pnew) { return pctx = pnew; }
34 
35 public:
37  {
38  pctx = BN_CTX_new();
39  if (pctx == NULL)
40  throw bignum_error("CAutoBN_CTX : BN_CTX_new() returned NULL");
41  }
42 
44  {
45  if (pctx != NULL)
46  BN_CTX_free(pctx);
47  }
48 
49  operator BN_CTX*() { return pctx; }
50  BN_CTX& operator*() { return *pctx; }
51  BN_CTX** operator&() { return &pctx; }
52  bool operator!() { return (pctx == NULL); }
53 };
54 
55 
57 class CBigNum : public BIGNUM
58 {
59 public:
61  {
62  BN_init(this);
63  }
64 
65  CBigNum(const CBigNum& b)
66  {
67  BN_init(this);
68  if (!BN_copy(this, &b))
69  {
70  BN_clear_free(this);
71  throw bignum_error("CBigNum::CBigNum(const CBigNum&) : BN_copy failed");
72  }
73  }
74 
76  {
77  if (!BN_copy(this, &b))
78  throw bignum_error("CBigNum::operator= : BN_copy failed");
79  return (*this);
80  }
81 
83  {
84  BN_clear_free(this);
85  }
86 
87  //CBigNum(char n) is not portable. Use 'signed char' or 'unsigned char'.
88  CBigNum(signed char n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
89  CBigNum(short n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
90  CBigNum(int n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
91  CBigNum(long n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
92  CBigNum(long long n) { BN_init(this); setint64(n); }
93  CBigNum(unsigned char n) { BN_init(this); setulong(n); }
94  CBigNum(unsigned short n) { BN_init(this); setulong(n); }
95  CBigNum(unsigned int n) { BN_init(this); setulong(n); }
96  CBigNum(unsigned long n) { BN_init(this); setulong(n); }
97  CBigNum(unsigned long long n) { BN_init(this); setuint64(n); }
98  explicit CBigNum(uint256 n) { BN_init(this); setuint256(n); }
99 
100  explicit CBigNum(const std::vector<unsigned char>& vch)
101  {
102  BN_init(this);
103  setvch(vch);
104  }
105 
106  void setulong(unsigned long n)
107  {
108  if (!BN_set_word(this, n))
109  throw bignum_error("CBigNum conversion from unsigned long : BN_set_word failed");
110  }
111 
112  unsigned long getulong() const
113  {
114  return BN_get_word(this);
115  }
116 
117  unsigned int getuint() const
118  {
119  return BN_get_word(this);
120  }
121 
122  int getint() const
123  {
124  BN_ULONG n = BN_get_word(this);
125  if (!BN_is_negative(this))
126  return (n > (BN_ULONG)std::numeric_limits<int>::max() ? std::numeric_limits<int>::max() : n);
127  else
128  return (n > (BN_ULONG)std::numeric_limits<int>::max() ? std::numeric_limits<int>::min() : -(int)n);
129  }
130 
131  void setint64(int64_t sn)
132  {
133  unsigned char pch[sizeof(sn) + 6];
134  unsigned char* p = pch + 4;
135  bool fNegative;
136  uint64_t n;
137 
138  if (sn < (int64_t)0)
139  {
140  // Since the minimum signed integer cannot be represented as positive so long as its type is signed,
141  // and it's not well-defined what happens if you make it unsigned before negating it,
142  // we instead increment the negative integer by 1, convert it, then increment the (now positive) unsigned integer by 1 to compensate
143  n = -(sn + 1);
144  ++n;
145  fNegative = true;
146  } else {
147  n = sn;
148  fNegative = false;
149  }
150 
151  bool fLeadingZeroes = true;
152  for (int i = 0; i < 8; i++)
153  {
154  unsigned char c = (n >> 56) & 0xff;
155  n <<= 8;
156  if (fLeadingZeroes)
157  {
158  if (c == 0)
159  continue;
160  if (c & 0x80)
161  *p++ = (fNegative ? 0x80 : 0);
162  else if (fNegative)
163  c |= 0x80;
164  fLeadingZeroes = false;
165  }
166  *p++ = c;
167  }
168  unsigned int nSize = p - (pch + 4);
169  pch[0] = (nSize >> 24) & 0xff;
170  pch[1] = (nSize >> 16) & 0xff;
171  pch[2] = (nSize >> 8) & 0xff;
172  pch[3] = (nSize) & 0xff;
173  BN_mpi2bn(pch, p - pch, this);
174  }
175 
176  void setuint64(uint64_t n)
177  {
178  unsigned char pch[sizeof(n) + 6];
179  unsigned char* p = pch + 4;
180  bool fLeadingZeroes = true;
181  for (int i = 0; i < 8; i++)
182  {
183  unsigned char c = (n >> 56) & 0xff;
184  n <<= 8;
185  if (fLeadingZeroes)
186  {
187  if (c == 0)
188  continue;
189  if (c & 0x80)
190  *p++ = 0;
191  fLeadingZeroes = false;
192  }
193  *p++ = c;
194  }
195  unsigned int nSize = p - (pch + 4);
196  pch[0] = (nSize >> 24) & 0xff;
197  pch[1] = (nSize >> 16) & 0xff;
198  pch[2] = (nSize >> 8) & 0xff;
199  pch[3] = (nSize) & 0xff;
200  BN_mpi2bn(pch, p - pch, this);
201  }
202 
204  {
205  unsigned char pch[sizeof(n) + 6];
206  unsigned char* p = pch + 4;
207  bool fLeadingZeroes = true;
208  unsigned char* pbegin = (unsigned char*)&n;
209  unsigned char* psrc = pbegin + sizeof(n);
210  while (psrc != pbegin)
211  {
212  unsigned char c = *(--psrc);
213  if (fLeadingZeroes)
214  {
215  if (c == 0)
216  continue;
217  if (c & 0x80)
218  *p++ = 0;
219  fLeadingZeroes = false;
220  }
221  *p++ = c;
222  }
223  unsigned int nSize = p - (pch + 4);
224  pch[0] = (nSize >> 24) & 0xff;
225  pch[1] = (nSize >> 16) & 0xff;
226  pch[2] = (nSize >> 8) & 0xff;
227  pch[3] = (nSize >> 0) & 0xff;
228  BN_mpi2bn(pch, p - pch, this);
229  }
230 
232  {
233  unsigned int nSize = BN_bn2mpi(this, NULL);
234  if (nSize < 4)
235  return 0;
236  std::vector<unsigned char> vch(nSize);
237  BN_bn2mpi(this, &vch[0]);
238  if (vch.size() > 4)
239  vch[4] &= 0x7f;
240  uint256 n = 0;
241  for (unsigned int i = 0, j = vch.size()-1; i < sizeof(n) && j >= 4; i++, j--)
242  ((unsigned char*)&n)[i] = vch[j];
243  return n;
244  }
245 
246  void setvch(const std::vector<unsigned char>& vch)
247  {
248  std::vector<unsigned char> vch2(vch.size() + 4);
249  unsigned int nSize = vch.size();
250  // BIGNUM's byte stream format expects 4 bytes of
251  // big endian size data info at the front
252  vch2[0] = (nSize >> 24) & 0xff;
253  vch2[1] = (nSize >> 16) & 0xff;
254  vch2[2] = (nSize >> 8) & 0xff;
255  vch2[3] = (nSize >> 0) & 0xff;
256  // swap data to big endian
257  reverse_copy(vch.begin(), vch.end(), vch2.begin() + 4);
258  BN_mpi2bn(&vch2[0], vch2.size(), this);
259  }
260 
261  std::vector<unsigned char> getvch() const
262  {
263  unsigned int nSize = BN_bn2mpi(this, NULL);
264  if (nSize <= 4)
265  return std::vector<unsigned char>();
266  std::vector<unsigned char> vch(nSize);
267  BN_bn2mpi(this, &vch[0]);
268  vch.erase(vch.begin(), vch.begin() + 4);
269  reverse(vch.begin(), vch.end());
270  return vch;
271  }
272 
273  // The "compact" format is a representation of a whole
274  // number N using an unsigned 32bit number similar to a
275  // floating point format.
276  // The most significant 8 bits are the unsigned exponent of base 256.
277  // This exponent can be thought of as "number of bytes of N".
278  // The lower 23 bits are the mantissa.
279  // Bit number 24 (0x800000) represents the sign of N.
280  // N = (-1^sign) * mantissa * 256^(exponent-3)
281  //
282  // Satoshi's original implementation used BN_bn2mpi() and BN_mpi2bn().
283  // MPI uses the most significant bit of the first byte as sign.
284  // Thus 0x1234560000 is compact (0x05123456)
285  // and 0xc0de000000 is compact (0x0600c0de)
286  // (0x05c0de00) would be -0x40de000000
287  //
288  // Bitcoin only uses this "compact" format for encoding difficulty
289  // targets, which are unsigned 256bit quantities. Thus, all the
290  // complexities of the sign bit and using base 256 are probably an
291  // implementation accident.
292  //
293  // This implementation directly uses shifts instead of going
294  // through an intermediate MPI representation.
295  CBigNum& SetCompact(unsigned int nCompact)
296  {
297  unsigned int nSize = nCompact >> 24;
298  bool fNegative =(nCompact & 0x00800000) != 0;
299  unsigned int nWord = nCompact & 0x007fffff;
300  if (nSize <= 3)
301  {
302  nWord >>= 8*(3-nSize);
303  BN_set_word(this, nWord);
304  }
305  else
306  {
307  BN_set_word(this, nWord);
308  BN_lshift(this, this, 8*(nSize-3));
309  }
310  BN_set_negative(this, fNegative);
311  return *this;
312  }
313 
314  unsigned int GetCompact() const
315  {
316  unsigned int nSize = BN_num_bytes(this);
317  unsigned int nCompact = 0;
318  if (nSize <= 3)
319  nCompact = BN_get_word(this) << 8*(3-nSize);
320  else
321  {
322  CBigNum bn;
323  BN_rshift(&bn, this, 8*(nSize-3));
324  nCompact = BN_get_word(&bn);
325  }
326  // The 0x00800000 bit denotes the sign.
327  // Thus, if it is already set, divide the mantissa by 256 and increase the exponent.
328  if (nCompact & 0x00800000)
329  {
330  nCompact >>= 8;
331  nSize++;
332  }
333  nCompact |= nSize << 24;
334  nCompact |= (BN_is_negative(this) ? 0x00800000 : 0);
335  return nCompact;
336  }
337 
338  void SetHex(const std::string& str)
339  {
340  // skip 0x
341  const char* psz = str.c_str();
342  while (isspace(*psz))
343  psz++;
344  bool fNegative = false;
345  if (*psz == '-')
346  {
347  fNegative = true;
348  psz++;
349  }
350  if (psz[0] == '0' && tolower(psz[1]) == 'x')
351  psz += 2;
352  while (isspace(*psz))
353  psz++;
354 
355  // hex string to bignum
356  *this = 0;
357  int n;
358  while ((n = HexDigit(*psz)) != -1)
359  {
360  *this <<= 4;
361  *this += n;
362  ++psz;
363  }
364  if (fNegative)
365  *this = 0 - *this;
366  }
367 
368  std::string ToString(int nBase=10) const
369  {
370  CAutoBN_CTX pctx;
371  CBigNum bnBase = nBase;
372  CBigNum bn0 = 0;
373  std::string str;
374  CBigNum bn = *this;
375  BN_set_negative(&bn, false);
376  CBigNum dv;
377  CBigNum rem;
378  if (BN_cmp(&bn, &bn0) == 0)
379  return "0";
380  while (BN_cmp(&bn, &bn0) > 0)
381  {
382  if (!BN_div(&dv, &rem, &bn, &bnBase, pctx))
383  throw bignum_error("CBigNum::ToString() : BN_div failed");
384  bn = dv;
385  unsigned int c = rem.getulong();
386  str += "0123456789abcdef"[c];
387  }
388  if (BN_is_negative(this))
389  str += "-";
390  reverse(str.begin(), str.end());
391  return str;
392  }
393 
394  std::string GetHex() const
395  {
396  return ToString(16);
397  }
398 
399  unsigned int GetSerializeSize(int nType=0, int nVersion=PROTOCOL_VERSION) const
400  {
401  return ::GetSerializeSize(getvch(), nType, nVersion);
402  }
403 
404  template<typename Stream>
405  void Serialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION) const
406  {
407  ::Serialize(s, getvch(), nType, nVersion);
408  }
409 
410  template<typename Stream>
411  void Unserialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION)
412  {
413  std::vector<unsigned char> vch;
414  ::Unserialize(s, vch, nType, nVersion);
415  setvch(vch);
416  }
417 
418 
419  bool operator!() const
420  {
421  return BN_is_zero(this);
422  }
423 
425  {
426  if (!BN_add(this, this, &b))
427  throw bignum_error("CBigNum::operator+= : BN_add failed");
428  return *this;
429  }
430 
432  {
433  *this = *this - b;
434  return *this;
435  }
436 
438  {
439  CAutoBN_CTX pctx;
440  if (!BN_mul(this, this, &b, pctx))
441  throw bignum_error("CBigNum::operator*= : BN_mul failed");
442  return *this;
443  }
444 
446  {
447  *this = *this / b;
448  return *this;
449  }
450 
452  {
453  *this = *this % b;
454  return *this;
455  }
456 
457  CBigNum& operator<<=(unsigned int shift)
458  {
459  if (!BN_lshift(this, this, shift))
460  throw bignum_error("CBigNum:operator<<= : BN_lshift failed");
461  return *this;
462  }
463 
464  CBigNum& operator>>=(unsigned int shift)
465  {
466  // Note: BN_rshift segfaults on 64-bit if 2^shift is greater than the number
467  // if built on ubuntu 9.04 or 9.10, probably depends on version of OpenSSL
468  CBigNum a = 1;
469  a <<= shift;
470  if (BN_cmp(&a, this) > 0)
471  {
472  *this = 0;
473  return *this;
474  }
475 
476  if (!BN_rshift(this, this, shift))
477  throw bignum_error("CBigNum:operator>>= : BN_rshift failed");
478  return *this;
479  }
480 
481 
483  {
484  // prefix operator
485  if (!BN_add(this, this, BN_value_one()))
486  throw bignum_error("CBigNum::operator++ : BN_add failed");
487  return *this;
488  }
489 
490  const CBigNum operator++(int)
491  {
492  // postfix operator
493  const CBigNum ret = *this;
494  ++(*this);
495  return ret;
496  }
497 
499  {
500  // prefix operator
501  CBigNum r;
502  if (!BN_sub(&r, this, BN_value_one()))
503  throw bignum_error("CBigNum::operator-- : BN_sub failed");
504  *this = r;
505  return *this;
506  }
507 
508  const CBigNum operator--(int)
509  {
510  // postfix operator
511  const CBigNum ret = *this;
512  --(*this);
513  return ret;
514  }
515 
516 
517  friend inline const CBigNum operator-(const CBigNum& a, const CBigNum& b);
518  friend inline const CBigNum operator/(const CBigNum& a, const CBigNum& b);
519  friend inline const CBigNum operator%(const CBigNum& a, const CBigNum& b);
520 };
521 
522 
523 
524 inline const CBigNum operator+(const CBigNum& a, const CBigNum& b)
525 {
526  CBigNum r;
527  if (!BN_add(&r, &a, &b))
528  throw bignum_error("CBigNum::operator+ : BN_add failed");
529  return r;
530 }
531 
532 inline const CBigNum operator-(const CBigNum& a, const CBigNum& b)
533 {
534  CBigNum r;
535  if (!BN_sub(&r, &a, &b))
536  throw bignum_error("CBigNum::operator- : BN_sub failed");
537  return r;
538 }
539 
540 inline const CBigNum operator-(const CBigNum& a)
541 {
542  CBigNum r(a);
543  BN_set_negative(&r, !BN_is_negative(&r));
544  return r;
545 }
546 
547 inline const CBigNum operator*(const CBigNum& a, const CBigNum& b)
548 {
549  CAutoBN_CTX pctx;
550  CBigNum r;
551  if (!BN_mul(&r, &a, &b, pctx))
552  throw bignum_error("CBigNum::operator* : BN_mul failed");
553  return r;
554 }
555 
556 inline const CBigNum operator/(const CBigNum& a, const CBigNum& b)
557 {
558  CAutoBN_CTX pctx;
559  CBigNum r;
560  if (!BN_div(&r, NULL, &a, &b, pctx))
561  throw bignum_error("CBigNum::operator/ : BN_div failed");
562  return r;
563 }
564 
565 inline const CBigNum operator%(const CBigNum& a, const CBigNum& b)
566 {
567  CAutoBN_CTX pctx;
568  CBigNum r;
569  if (!BN_mod(&r, &a, &b, pctx))
570  throw bignum_error("CBigNum::operator% : BN_div failed");
571  return r;
572 }
573 
574 inline const CBigNum operator<<(const CBigNum& a, unsigned int shift)
575 {
576  CBigNum r;
577  if (!BN_lshift(&r, &a, shift))
578  throw bignum_error("CBigNum:operator<< : BN_lshift failed");
579  return r;
580 }
581 
582 inline const CBigNum operator>>(const CBigNum& a, unsigned int shift)
583 {
584  CBigNum r = a;
585  r >>= shift;
586  return r;
587 }
588 
589 inline bool operator==(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) == 0); }
590 inline bool operator!=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) != 0); }
591 inline bool operator<=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) <= 0); }
592 inline bool operator>=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) >= 0); }
593 inline bool operator<(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) < 0); }
594 inline bool operator>(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) > 0); }
595 
596 #endif
CBigNum(unsigned int n)
Definition: bignum.h:95
const CBigNum operator-(const CBigNum &a, const CBigNum &b)
Definition: bignum.h:532
BN_CTX ** operator&()
Definition: bignum.h:51
bool operator!=(const CBigNum &a, const CBigNum &b)
Definition: bignum.h:590
CBigNum(unsigned long n)
Definition: bignum.h:96
bool operator==(const CBigNum &a, const CBigNum &b)
Definition: bignum.h:589
uint256 getuint256() const
Definition: bignum.h:231
bool operator<(const CBigNum &a, const CBigNum &b)
Definition: bignum.h:593
CBigNum(short n)
Definition: bignum.h:89
bignum_error(const std::string &str)
Definition: bignum.h:24
CBigNum & operator>>=(unsigned int shift)
Definition: bignum.h:464
bool operator!()
Definition: bignum.h:52
std::string GetHex() const
Definition: bignum.h:394
CBigNum & operator/=(const CBigNum &b)
Definition: bignum.h:445
const CBigNum operator%(const CBigNum &a, const CBigNum &b)
Definition: bignum.h:565
void setuint256(uint256 n)
Definition: bignum.h:203
STL namespace.
CBigNum & operator<<=(unsigned int shift)
Definition: bignum.h:457
unsigned long getulong() const
Definition: bignum.h:112
CBigNum(unsigned char n)
Definition: bignum.h:93
RAII encapsulated BN_CTX (OpenSSL bignum context)
Definition: bignum.h:29
CBigNum & operator++()
Definition: bignum.h:482
void setulong(unsigned long n)
Definition: bignum.h:106
CBigNum & operator%=(const CBigNum &b)
Definition: bignum.h:451
const CBigNum operator/(const CBigNum &a, const CBigNum &b)
Definition: bignum.h:556
const CBigNum operator<<(const CBigNum &a, unsigned int shift)
Definition: bignum.h:574
BN_CTX * operator=(BN_CTX *pnew)
Definition: bignum.h:33
const CBigNum operator*(const CBigNum &a, const CBigNum &b)
Definition: bignum.h:547
void Unserialize(Stream &s, int nType=0, int nVersion=PROTOCOL_VERSION)
Definition: bignum.h:411
signed char HexDigit(char c)
Definition: uint256.h:17
CBigNum & SetCompact(unsigned int nCompact)
Definition: bignum.h:295
bool operator>(const CBigNum &a, const CBigNum &b)
Definition: bignum.h:594
CBigNum(const std::vector< unsigned char > &vch)
Definition: bignum.h:100
bool operator!() const
Definition: bignum.h:419
unsigned int GetSerializeSize(char a, int, int=0)
Definition: serialize.h:105
CBigNum(long long n)
Definition: bignum.h:92
const CBigNum operator>>(const CBigNum &a, unsigned int shift)
Definition: bignum.h:582
const CBigNum operator--(int)
Definition: bignum.h:508
CBigNum & operator*=(const CBigNum &b)
Definition: bignum.h:437
bool operator<=(const CBigNum &a, const CBigNum &b)
Definition: bignum.h:591
~CAutoBN_CTX()
Definition: bignum.h:43
CBigNum(signed char n)
Definition: bignum.h:88
const CBigNum operator+(const CBigNum &a, const CBigNum &b)
Definition: bignum.h:524
unsigned int getuint() const
Definition: bignum.h:117
C++ wrapper for BIGNUM (OpenSSL bignum)
Definition: bignum.h:57
BN_CTX * pctx
Definition: bignum.h:32
std::vector< unsigned char > getvch() const
Definition: bignum.h:261
CBigNum(int n)
Definition: bignum.h:90
friend const CBigNum operator%(const CBigNum &a, const CBigNum &b)
Definition: bignum.h:565
CBigNum(long n)
Definition: bignum.h:91
CAutoBN_CTX()
Definition: bignum.h:36
Errors thrown by the bignum class.
Definition: bignum.h:21
unsigned int GetSerializeSize(int nType=0, int nVersion=PROTOCOL_VERSION) const
Definition: bignum.h:399
bool operator>=(const CBigNum &a, const CBigNum &b)
Definition: bignum.h:592
CBigNum & operator-=(const CBigNum &b)
Definition: bignum.h:431
void SetHex(const std::string &str)
Definition: bignum.h:338
int getint() const
Definition: bignum.h:122
void setuint64(uint64_t n)
Definition: bignum.h:176
256-bit unsigned integer
Definition: uint256.h:531
void setvch(const std::vector< unsigned char > &vch)
Definition: bignum.h:246
CBigNum(unsigned short n)
Definition: bignum.h:94
static const int PROTOCOL_VERSION
Definition: version.h:29
void setint64(int64_t sn)
Definition: bignum.h:131
CBigNum & operator=(const CBigNum &b)
Definition: bignum.h:75
CBigNum & operator--()
Definition: bignum.h:498
unsigned int GetCompact() const
Definition: bignum.h:314
CBigNum & operator+=(const CBigNum &b)
Definition: bignum.h:424
const CBigNum operator++(int)
Definition: bignum.h:490
~CBigNum()
Definition: bignum.h:82
BN_CTX & operator*()
Definition: bignum.h:50
friend const CBigNum operator-(const CBigNum &a, const CBigNum &b)
Definition: bignum.h:532
std::string ToString(int nBase=10) const
Definition: bignum.h:368
CBigNum(const CBigNum &b)
Definition: bignum.h:65
CBigNum()
Definition: bignum.h:60
friend const CBigNum operator/(const CBigNum &a, const CBigNum &b)
Definition: bignum.h:556
CBigNum(uint256 n)
Definition: bignum.h:98
CBigNum(unsigned long long n)
Definition: bignum.h:97
void Serialize(Stream &s, int nType=0, int nVersion=PROTOCOL_VERSION) const
Definition: bignum.h:405