Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
base58.cpp
Go to the documentation of this file.
1// Copyright (c) 2009-2010 Satoshi Nakamoto
2// Copyright (c) 2009-2012 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
7//
8// Why base-58 instead of standard base-64 encoding?
9// - Don't want 0OIl characters that look the same in some fonts and
10// could be used to create visually identical looking account numbers.
11// - A string with non-alphanumeric characters is not as easily accepted as an account number.
12// - E-mail usually won't line-break if there's no punctuation to break at.
13// - Doubleclicking selects the whole number as one word if it's all alphanumeric.
14//
15#ifndef BITCOIN_BASE58_H
16#define BITCOIN_BASE58_H
17
18#include <string>
19#include <vector>
20#include <limits>
21#include <algorithm>
22
23#include <fc/crypto/base58.hpp>
24#include <fc/log/logger.hpp>
25#include <fc/string.hpp>
27
28#include <stdexcept>
29#include <vector>
30#include <openssl/bn.h>
31
33class bignum_error : public std::runtime_error
34{
35public:
36 explicit bignum_error(const std::string& str) : std::runtime_error(str) {}
37};
38
39
42{
43protected:
44 BN_CTX* pctx;
45 BN_CTX* operator=(BN_CTX* pnew) { return pctx = pnew; }
46
47public:
49 {
50 pctx = BN_CTX_new();
51 if (pctx == NULL)
52 throw bignum_error("CAutoBN_CTX : BN_CTX_new() returned NULL");
53 }
54
56 {
57 if (pctx != NULL)
58 BN_CTX_free(pctx);
59 }
60
61 operator BN_CTX*() { return pctx; }
62 BN_CTX& operator*() { return *pctx; }
63 BN_CTX** operator&() { return &pctx; }
64 bool operator!() { return (pctx == NULL); }
65};
66
67
70{
71 BIGNUM* bn;
72public:
74 : bn(BN_new()) {}
75
76 CBigNum(const CBigNum& b)
77 : CBigNum()
78 {
79 if (!BN_copy(bn, b.bn))
80 {
81 BN_clear_free(bn);
82 throw bignum_error("CBigNum::CBigNum(const CBigNum&) : BN_copy failed");
83 }
84 }
85
87 {
88 if (!BN_copy(bn, b.bn))
89 throw bignum_error("CBigNum::operator= : BN_copy failed");
90 return (*this);
91 }
92
94 {
95 BN_clear_free(bn);
96 }
97
98 //CBigNum(char n) is not portable. Use 'signed char' or 'unsigned char'.
99 CBigNum(signed char n) :CBigNum() { if (n >= 0) setulong(n); else setint64(n); }
100 CBigNum(short n) :CBigNum() { if (n >= 0) setulong(n); else setint64(n); }
101 CBigNum(int n) :CBigNum() { if (n >= 0) setulong(n); else setint64(n); }
103 CBigNum(unsigned char n) :CBigNum() { setulong(n); }
104 CBigNum(unsigned short n) :CBigNum() { setulong(n); }
105 CBigNum(unsigned int n) :CBigNum() { setulong(n); }
107
108 explicit CBigNum(const std::vector<unsigned char>& vch)
109 : CBigNum()
110 {
111 setvch(vch);
112 }
113
114 void setulong(unsigned long n)
115 {
116 if (!BN_set_word(bn, n))
117 throw bignum_error("CBigNum conversion from unsigned long : BN_set_word failed");
118 }
119
120 unsigned long getulong() const
121 {
122 return BN_get_word(bn);
123 }
124
125 unsigned int getuint() const
126 {
127 return BN_get_word(bn);
128 }
129
130 int getint() const
131 {
132 unsigned long n = BN_get_word(bn);
133 if (!BN_is_negative(bn))
134 return (n > (unsigned long)std::numeric_limits<int>::max() ? std::numeric_limits<int>::max() : n);
135 else
136 return (n > (unsigned long)std::numeric_limits<int>::max() ? std::numeric_limits<int>::min() : -(int)n);
137 }
138
140 {
141 unsigned char pch[sizeof(n) + 6];
142 unsigned char* p = pch + 4;
143 bool fNegative = false;
144 if (n < (int64_t)0)
145 {
146 n = -n;
147 fNegative = true;
148 }
149 bool fLeadingZeroes = true;
150 for (int i = 0; i < 8; i++)
151 {
152 unsigned char c = (n >> 56) & 0xff;
153 n <<= 8;
154 if (fLeadingZeroes)
155 {
156 if (c == 0)
157 continue;
158 if (c & 0x80)
159 *p++ = (fNegative ? 0x80 : 0);
160 else if (fNegative)
161 c |= 0x80;
162 fLeadingZeroes = false;
163 }
164 *p++ = c;
165 }
166 unsigned int nSize = p - (pch + 4);
167 pch[0] = (nSize >> 24) & 0xff;
168 pch[1] = (nSize >> 16) & 0xff;
169 pch[2] = (nSize >> 8) & 0xff;
170 pch[3] = (nSize) & 0xff;
171 BN_mpi2bn(pch, p - pch, bn);
172 }
173
175 {
176 unsigned char pch[sizeof(n) + 6];
177 unsigned char* p = pch + 4;
178 bool fLeadingZeroes = true;
179 for (int i = 0; i < 8; i++)
180 {
181 unsigned char c = (n >> 56) & 0xff;
182 n <<= 8;
183 if (fLeadingZeroes)
184 {
185 if (c == 0)
186 continue;
187 if (c & 0x80)
188 *p++ = 0;
189 fLeadingZeroes = false;
190 }
191 *p++ = c;
192 }
193 unsigned int nSize = p - (pch + 4);
194 pch[0] = (nSize >> 24) & 0xff;
195 pch[1] = (nSize >> 16) & 0xff;
196 pch[2] = (nSize >> 8) & 0xff;
197 pch[3] = (nSize) & 0xff;
198 BN_mpi2bn(pch, p - pch, bn);
199 }
200
201
202 void setvch(const std::vector<unsigned char>& vch)
203 {
204 std::vector<unsigned char> vch2(vch.size() + 4);
205 unsigned int nSize = vch.size();
206 // BIGNUM's byte stream format expects 4 bytes of
207 // big endian size data info at the front
208 vch2[0] = (nSize >> 24) & 0xff;
209 vch2[1] = (nSize >> 16) & 0xff;
210 vch2[2] = (nSize >> 8) & 0xff;
211 vch2[3] = (nSize >> 0) & 0xff;
212 // swap data to big endian
213 reverse_copy(vch.begin(), vch.end(), vch2.begin() + 4);
214 BN_mpi2bn(&vch2[0], vch2.size(), bn);
215 }
216
217 std::vector<unsigned char> getvch() const
218 {
219 unsigned int nSize = BN_bn2mpi(bn, NULL);
220 if (nSize <= 4)
221 return std::vector<unsigned char>();
222 std::vector<unsigned char> vch(nSize);
223 BN_bn2mpi(bn, &vch[0]);
224 vch.erase(vch.begin(), vch.begin() + 4);
225 reverse(vch.begin(), vch.end());
226 return vch;
227 }
228
229 CBigNum& SetCompact(unsigned int nCompact)
230 {
231 unsigned int nSize = nCompact >> 24;
232 std::vector<unsigned char> vch(4 + nSize);
233 vch[3] = nSize;
234 if (nSize >= 1) vch[4] = (nCompact >> 16) & 0xff;
235 if (nSize >= 2) vch[5] = (nCompact >> 8) & 0xff;
236 if (nSize >= 3) vch[6] = (nCompact >> 0) & 0xff;
237 BN_mpi2bn(&vch[0], vch.size(), bn);
238 return *this;
239 }
240
241 unsigned int GetCompact() const
242 {
243 unsigned int nSize = BN_bn2mpi(bn, NULL);
244 std::vector<unsigned char> vch(nSize);
245 nSize -= 4;
246 BN_bn2mpi(bn, &vch[0]);
247 unsigned int nCompact = nSize << 24;
248 if (nSize >= 1) nCompact |= (vch[4] << 16);
249 if (nSize >= 2) nCompact |= (vch[5] << 8);
250 if (nSize >= 3) nCompact |= (vch[6] << 0);
251 return nCompact;
252 }
253
254 void SetHex(const std::string& str)
255 {
256 // skip 0x
257 const char* psz = str.c_str();
258 while (isspace(*psz))
259 psz++;
260 bool fNegative = false;
261 if (*psz == '-')
262 {
263 fNegative = true;
264 psz++;
265 }
266 if (psz[0] == '0' && tolower(psz[1]) == 'x')
267 psz += 2;
268 while (isspace(*psz))
269 psz++;
270
271 // hex string to bignum
272 static signed char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };
273 *this = 0;
274 while (isxdigit(*psz))
275 {
276 *this <<= 4;
277 int n = phexdigit[(unsigned char)*psz++];
278 *this += n;
279 }
280 if (fNegative)
281 BN_set_negative(bn, 1);
282 }
283
284 std::string ToString(int nBase=10) const
285 {
286 CAutoBN_CTX pctx;
287 CBigNum bnBase = nBase;
288 CBigNum bn0 = 0;
289 std::string str;
290 CBigNum bn = *this;
291 BN_set_negative(bn.bn, false);
292 CBigNum dv;
293 CBigNum rem;
294 if (BN_cmp(bn.bn, bn0.bn) == 0)
295 return "0";
296 while (BN_cmp(bn.bn, bn0.bn) > 0)
297 {
298 if (!BN_div(dv.bn, rem.bn, bn.bn, bnBase.bn, pctx))
299 throw bignum_error("CBigNum::ToString() : BN_div failed");
300 bn = dv;
301 unsigned int c = rem.getulong();
302 str += "0123456789abcdef"[c];
303 }
304 if (BN_is_negative(this->bn))
305 str += "-";
306 reverse(str.begin(), str.end());
307 return str;
308 }
309
310 std::string GetHex() const
311 {
312 return ToString(16);
313 }
314
315
316
317 bool operator!() const
318 {
319 return BN_is_zero(bn);
320 }
321
323 {
324 if (!BN_add(bn, bn, b.bn))
325 throw bignum_error("CBigNum::operator+= : BN_add failed");
326 return *this;
327 }
328
330 {
331 if (!BN_sub(bn, bn, b.bn))
332 throw bignum_error("CBigNum::operator-= : BN_sub failed");
333 return *this;
334 }
335
337 {
338 CAutoBN_CTX pctx;
339 if (!BN_mul(bn, bn, b.bn, pctx))
340 throw bignum_error("CBigNum::operator*= : BN_mul failed");
341 return *this;
342 }
343
345 {
346 CAutoBN_CTX pctx;
347 if (!BN_div(bn, NULL, bn, b.bn, pctx))
348 throw bignum_error("CBigNum::operator/= : BN_div failed");
349 return *this;
350 }
351
353 {
354 CAutoBN_CTX pctx;
355 if (!BN_div(NULL, bn, bn, b.bn, pctx))
356 throw bignum_error("CBigNum::operator%= : BN_div failed");
357 return *this;
358 }
359
360 CBigNum& operator<<=(unsigned int shift)
361 {
362 if (!BN_lshift(bn, bn, shift))
363 throw bignum_error("CBigNum:operator<<= : BN_lshift failed");
364 return *this;
365 }
366
367 CBigNum& operator>>=(unsigned int shift)
368 {
369 // Note: BN_rshift segfaults on 64-bit if 2^shift is greater than the number
370 // if built on ubuntu 9.04 or 9.10, probably depends on version of openssl
371 CBigNum a = 1;
372 a <<= shift;
373 if (BN_cmp(a.bn, bn) > 0)
374 {
375 *this = 0;
376 return *this;
377 }
378
379 if (!BN_rshift(bn, bn, shift))
380 throw bignum_error("CBigNum:operator>>= : BN_rshift failed");
381 return *this;
382 }
383
384
386 {
387 // prefix operator
388 if (!BN_add(bn, bn, BN_value_one()))
389 throw bignum_error("CBigNum::operator++ : BN_add failed");
390 return *this;
391 }
392
394 {
395 // postfix operator
396 const CBigNum ret = *this;
397 ++(*this);
398 return ret;
399 }
400
402 {
403 // prefix operator
404 CBigNum r;
405 if (!BN_sub(r.bn, bn, BN_value_one()))
406 throw bignum_error("CBigNum::operator-- : BN_sub failed");
407 *this = r;
408 return *this;
409 }
410
412 {
413 // postfix operator
414 const CBigNum ret = *this;
415 --(*this);
416 return ret;
417 }
418
419 const BIGNUM* to_bignum() const {
420 return bn;
421 }
423 return bn;
424 }
425};
426
427
428
429inline const CBigNum operator+(const CBigNum& a, const CBigNum& b)
430{
431 CBigNum r;
432 if (!BN_add(r.to_bignum(), a.to_bignum(), b.to_bignum()))
433 throw bignum_error("CBigNum::operator+ : BN_add failed");
434 return r;
435}
436
437inline const CBigNum operator-(const CBigNum& a, const CBigNum& b)
438{
439 CBigNum r;
440 if (!BN_sub(r.to_bignum(), a.to_bignum(), b.to_bignum()))
441 throw bignum_error("CBigNum::operator- : BN_sub failed");
442 return r;
443}
444
445inline const CBigNum operator-(const CBigNum& a)
446{
447 CBigNum r(a);
448 BN_set_negative(r.to_bignum(), !BN_is_negative(r.to_bignum()));
449 return r;
450}
451
452inline const CBigNum operator*(const CBigNum& a, const CBigNum& b)
453{
454 CAutoBN_CTX pctx;
455 CBigNum r;
456 if (!BN_mul(r.to_bignum(), a.to_bignum(), b.to_bignum(), pctx))
457 throw bignum_error("CBigNum::operator* : BN_mul failed");
458 return r;
459}
460
461inline const CBigNum operator/(const CBigNum& a, const CBigNum& b)
462{
463 CAutoBN_CTX pctx;
464 CBigNum r;
465 if (!BN_div(r.to_bignum(), NULL, a.to_bignum(), b.to_bignum(), pctx))
466 throw bignum_error("CBigNum::operator/ : BN_div failed");
467 return r;
468}
469
470inline const CBigNum operator%(const CBigNum& a, const CBigNum& b)
471{
472 CAutoBN_CTX pctx;
473 CBigNum r;
474 if (!BN_mod(r.to_bignum(), a.to_bignum(), b.to_bignum(), pctx))
475 throw bignum_error("CBigNum::operator% : BN_div failed");
476 return r;
477}
478
479inline const CBigNum operator<<(const CBigNum& a, unsigned int shift)
480{
481 CBigNum r;
482 if (!BN_lshift(r.to_bignum(), a.to_bignum(), shift))
483 throw bignum_error("CBigNum:operator<< : BN_lshift failed");
484 return r;
485}
486
487inline const CBigNum operator>>(const CBigNum& a, unsigned int shift)
488{
489 CBigNum r = a;
490 r >>= shift;
491 return r;
492}
493
494inline bool operator==(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) == 0); }
495inline bool operator!=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) != 0); }
496inline bool operator<=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) <= 0); }
497inline bool operator>=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) >= 0); }
498inline bool operator<(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) < 0); }
499inline bool operator>(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) > 0); }
500
501
502static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
503
504// Encode a byte sequence as a base58-encoded string
505inline std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend, const fc::yield_function_t& yield)
506{
507 CAutoBN_CTX pctx;
508 CBigNum bn58 = 58;
509 CBigNum bn0 = 0;
510
511 // Convert big endian data to little endian
512 // Extra zero at the end make sure bignum will interpret as a positive number
513 std::vector<unsigned char> vchTmp(pend-pbegin+1, 0);
514 yield();
515 reverse_copy(pbegin, pend, vchTmp.begin());
516 yield();
517
518 // Convert little endian data to bignum
519 CBigNum bn;
520 bn.setvch(vchTmp);
521
522 // Convert bignum to std::string
523 std::string str;
524 // Expected size increase from base58 conversion is approximately 137%
525 // use 138% to be safe
526 str.reserve((pend - pbegin) * 138 / 100 + 1);
527 CBigNum dv;
528 CBigNum rem;
529 while (bn > bn0)
530 {
531 yield();
532 if (!BN_div(dv.to_bignum(), rem.to_bignum(), bn.to_bignum(), bn58.to_bignum(), pctx))
533 throw bignum_error("EncodeBase58 : BN_div failed");
534 bn = dv;
535 unsigned int c = rem.getulong();
536 str += pszBase58[c];
537 }
538
539 // Leading zeroes encoded as base58 zeros
540 for (const unsigned char* p = pbegin; p < pend && *p == 0; p++)
541 str += pszBase58[0];
542
543 yield();
544 // Convert little endian std::string to big endian
545 reverse(str.begin(), str.end());
546// slog( "Encode '%s'", str.c_str() );
547 yield();
548
549 return str;
550}
551
552// Encode a byte vector as a base58-encoded string
553inline std::string EncodeBase58(const std::vector<unsigned char>& vch, const fc::yield_function_t& yield)
554{
555 return EncodeBase58(&vch[0], &vch[0] + vch.size(), yield);
556}
557
558// Decode a base58-encoded string psz into byte vector vchRet
559// returns true if decoding is succesful
560inline bool DecodeBase58(const char* psz, std::vector<unsigned char>& vchRet)
561{
562 CAutoBN_CTX pctx;
563 vchRet.clear();
564 CBigNum bn58 = 58;
565 CBigNum bn = 0;
566 CBigNum bnChar;
567 while (isspace(*psz))
568 psz++;
569
570 // Convert big endian string to bignum
571 for (const char* p = psz; *p; p++)
572 {
573 const char* p1 = strchr(pszBase58, *p);
574 if (p1 == NULL)
575 {
576 while (isspace(*p))
577 p++;
578 if (*p != '\0') {
579 //slog( "%s '%c'", pszBase58,*p );
580 return false;
581 }
582 break;
583 }
584 bnChar.setulong(p1 - pszBase58);
585 if (!BN_mul(bn.to_bignum(), bn.to_bignum(), bn58.to_bignum(), pctx))
586 throw bignum_error("DecodeBase58 : BN_mul failed");
587 bn += bnChar;
588 }
589
590 // Get bignum as little endian data
591 std::vector<unsigned char> vchTmp = bn.getvch();
592
593 // Trim off sign byte if present
594 if (vchTmp.size() >= 2 && vchTmp.end()[-1] == 0 && vchTmp.end()[-2] >= 0x80)
595 vchTmp.erase(vchTmp.end()-1);
596
597 // Restore leading zeros
598 int nLeadingZeros = 0;
599 for (const char* p = psz; *p == pszBase58[0]; p++)
600 nLeadingZeros++;
601 vchRet.assign(nLeadingZeros + vchTmp.size(), 0);
602
603 // Convert little endian data to big endian
604 reverse_copy(vchTmp.begin(), vchTmp.end(), vchRet.end() - vchTmp.size());
605 return true;
606}
607
608// Decode a base58-encoded string str into byte vector vchRet
609// returns true if decoding is succesful
610inline bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet)
611{
612 return DecodeBase58(str.c_str(), vchRet);
613}
614
615
616namespace fc {
617
618std::string to_base58( const char* d, size_t s, const fc::yield_function_t& yield ) {
619 return EncodeBase58( (const unsigned char*)d, (const unsigned char*)d+s, yield );
620}
621
622std::string to_base58( const std::vector<char>& d, const fc::yield_function_t& yield )
623{
624 if( d.size() )
625 return to_base58( d.data(), d.size(), yield );
626 return std::string();
627}
628std::vector<char> from_base58( const std::string& base58_str ) {
629 std::vector<unsigned char> out;
630 if( !DecodeBase58( base58_str.c_str(), out ) ) {
631 FC_THROW_EXCEPTION( parse_error_exception, "Unable to decode base58 string ${base58_str}", ("base58_str",base58_str) );
632 }
633 return std::vector<char>((const char*)out.data(), ((const char*)out.data())+out.size() );
634}
638size_t from_base58( const std::string& base58_str, char* out_data, size_t out_data_len ) {
639 //slog( "%s", base58_str.c_str() );
640 std::vector<unsigned char> out;
641 if( !DecodeBase58( base58_str.c_str(), out ) ) {
642 FC_THROW_EXCEPTION( parse_error_exception, "Unable to decode base58 string ${base58_str}", ("base58_str",base58_str) );
643 }
644 FC_ASSERT( out.size() <= out_data_len );
645 memcpy( out_data, out.data(), out.size() );
646 return out.size();
647}
648}
649
650#endif
const CBigNum operator>>(const CBigNum &a, unsigned int shift)
Definition base58.cpp:487
bool operator!=(const CBigNum &a, const CBigNum &b)
Definition base58.cpp:495
bool DecodeBase58(const char *psz, std::vector< unsigned char > &vchRet)
Definition base58.cpp:560
std::string EncodeBase58(const unsigned char *pbegin, const unsigned char *pend, const fc::yield_function_t &yield)
Definition base58.cpp:505
const CBigNum operator*(const CBigNum &a, const CBigNum &b)
Definition base58.cpp:452
bool operator<(const CBigNum &a, const CBigNum &b)
Definition base58.cpp:498
const CBigNum operator+(const CBigNum &a, const CBigNum &b)
Definition base58.cpp:429
const CBigNum operator<<(const CBigNum &a, unsigned int shift)
Definition base58.cpp:479
const CBigNum operator%(const CBigNum &a, const CBigNum &b)
Definition base58.cpp:470
bool operator<=(const CBigNum &a, const CBigNum &b)
Definition base58.cpp:496
const CBigNum operator/(const CBigNum &a, const CBigNum &b)
Definition base58.cpp:461
bool operator>=(const CBigNum &a, const CBigNum &b)
Definition base58.cpp:497
bool operator>(const CBigNum &a, const CBigNum &b)
Definition base58.cpp:499
const CBigNum operator-(const CBigNum &a, const CBigNum &b)
Definition base58.cpp:437
bool operator==(const CBigNum &a, const CBigNum &b)
Definition base58.cpp:494
const mie::Vuint & p
Definition bn.cpp:27
const mie::Vuint & r
Definition bn.cpp:28
BN_CTX ** operator&()
Definition base58.cpp:63
BN_CTX * pctx
Definition base58.cpp:44
bool operator!()
Definition base58.cpp:64
BN_CTX * operator=(BN_CTX *pnew)
Definition base58.cpp:45
BN_CTX & operator*()
Definition base58.cpp:62
std::vector< unsigned char > getvch() const
Definition base58.cpp:217
unsigned long getulong() const
Definition base58.cpp:120
~CBigNum()
Definition base58.cpp:93
CBigNum(short n)
Definition base58.cpp:100
std::string ToString(int nBase=10) const
Definition base58.cpp:284
const CBigNum operator--(int)
Definition base58.cpp:411
CBigNum & operator*=(const CBigNum &b)
Definition base58.cpp:336
CBigNum & operator+=(const CBigNum &b)
Definition base58.cpp:322
CBigNum()
Definition base58.cpp:73
CBigNum(signed char n)
Definition base58.cpp:99
CBigNum & operator/=(const CBigNum &b)
Definition base58.cpp:344
CBigNum(unsigned short n)
Definition base58.cpp:104
CBigNum & operator<<=(unsigned int shift)
Definition base58.cpp:360
BIGNUM * to_bignum()
Definition base58.cpp:422
unsigned int getuint() const
Definition base58.cpp:125
CBigNum(const CBigNum &b)
Definition base58.cpp:76
CBigNum & operator%=(const CBigNum &b)
Definition base58.cpp:352
std::string GetHex() const
Definition base58.cpp:310
CBigNum(unsigned int n)
Definition base58.cpp:105
CBigNum & operator--()
Definition base58.cpp:401
bool operator!() const
Definition base58.cpp:317
CBigNum(int n)
Definition base58.cpp:101
void setint64(int64_t n)
Definition base58.cpp:139
void SetHex(const std::string &str)
Definition base58.cpp:254
CBigNum & operator=(const CBigNum &b)
Definition base58.cpp:86
const CBigNum operator++(int)
Definition base58.cpp:393
unsigned int GetCompact() const
Definition base58.cpp:241
void setvch(const std::vector< unsigned char > &vch)
Definition base58.cpp:202
const BIGNUM * to_bignum() const
Definition base58.cpp:419
CBigNum & operator-=(const CBigNum &b)
Definition base58.cpp:329
CBigNum & operator++()
Definition base58.cpp:385
void setulong(unsigned long n)
Definition base58.cpp:114
CBigNum(int64_t n)
Definition base58.cpp:102
CBigNum(const std::vector< unsigned char > &vch)
Definition base58.cpp:108
void setuint64(uint64_t n)
Definition base58.cpp:174
CBigNum & SetCompact(unsigned int nCompact)
Definition base58.cpp:229
CBigNum & operator>>=(unsigned int shift)
Definition base58.cpp:367
CBigNum(uint64_t n)
Definition base58.cpp:106
int getint() const
Definition base58.cpp:130
CBigNum(unsigned char n)
Definition base58.cpp:103
bignum_error(const std::string &str)
Definition base58.cpp:36
Defines exception's used by fc.
#define FC_THROW_EXCEPTION(EXCEPTION, FORMAT,...)
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
bignum_st BIGNUM
Definition bigint.hpp:7
Definition bn.h:56
namespace sysio::chain
Definition authority.cpp:3
std::string to_base58(const char *d, size_t s, const fc::yield_function_t &yield)
Definition base58.cpp:618
std::vector< char > from_base58(const std::string &base58_str)
Definition base58.cpp:628
Definition name.hpp:106
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
signed __int64 int64_t
Definition stdint.h:135
unsigned __int64 uint64_t
Definition stdint.h:136
CK_ULONG d
CK_RV ret
char * s
memcpy((char *) pInfo->slotDescription, s, l)