Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
bigint.hpp
Go to the documentation of this file.
1#pragma once
2#include <stdint.h>
3#include <fc/string.hpp>
4#include <fc/vector.hpp>
5
6struct bignum_st;
7typedef bignum_st BIGNUM;
8
9namespace fc {
10 class bigint {
11 public:
12 bigint( const std::vector<char>& bige );
13 bigint( const char* bige, uint32_t l );
15 bigint( );
16 bigint( const bigint& c );
17 bigint( bigint&& c );
18 explicit bigint( BIGNUM* n );
19 ~bigint();
20
21 bigint& operator = ( const bigint& a );
23
24 explicit operator bool()const;
25
26 bool is_negative()const;
27 int64_t to_int64()const;
28
29 int64_t log2()const;
30 bigint exp( const bigint& c )const;
31
32 static bigint random( uint32_t bits, int t, int );
33
34 bool operator < ( const bigint& c )const;
35 bool operator > ( const bigint& c )const;
36 bool operator >= ( const bigint& c )const;
37 bool operator == ( const bigint& c )const;
38 bool operator != ( const bigint& c )const;
39
40 bigint operator + ( const bigint& a )const;
41 bigint operator * ( const bigint& a )const;
42 bigint operator / ( const bigint& a )const;
43 bigint operator % ( const bigint& a )const;
44 bigint operator /= ( const bigint& a );
45 bigint operator *= ( const bigint& a );
46 bigint& operator += ( const bigint& a );
47 bigint& operator -= ( const bigint& a );
50 bigint operator - ( const bigint& a )const;
51
52
53 bigint operator++(int);
55 bigint operator--(int);
57
58 operator fc::string()const;
59
60 // returns bignum as bigendian bytes
61 operator std::vector<char>()const;
62
63 BIGNUM* dup()const;
64
65 BIGNUM* get()const { return n; }
66 private:
67 BIGNUM* n;
68 };
69
70 class variant;
72 void to_variant( const bigint& bi, variant& v );
74 void from_variant( const variant& v, bigint& bi );
75} // namespace fc
76
bigint & operator--()
Definition bigint.cpp:98
bool operator>=(const bigint &c) const
Definition bigint.cpp:69
bigint & operator=(const bigint &a)
Definition bigint.cpp:194
bigint operator*(const bigint &a) const
Definition bigint.cpp:122
bigint operator+(const bigint &a) const
Definition bigint.cpp:103
bigint & operator<<=(uint32_t i)
Definition bigint.cpp:165
BIGNUM * dup() const
Definition bigint.cpp:27
bigint operator/(const bigint &a) const
Definition bigint.cpp:129
static bigint random(uint32_t bits, int t, int)
bool operator==(const bigint &c) const
Definition bigint.cpp:72
bool operator>(const bigint &c) const
Definition bigint.cpp:66
bigint operator%(const bigint &a) const
Definition bigint.cpp:136
bigint & operator+=(const bigint &a)
Definition bigint.cpp:108
bool is_negative() const
Definition bigint.cpp:51
bigint exp(const bigint &c) const
Definition bigint.cpp:180
bigint & operator-=(const bigint &a)
Definition bigint.cpp:114
bool operator<(const bigint &c) const
Definition bigint.cpp:63
int64_t to_int64() const
Definition bigint.cpp:53
bigint operator*=(const bigint &a)
Definition bigint.cpp:152
bool operator!=(const bigint &c) const
Definition bigint.cpp:75
bigint & operator>>=(uint32_t i)
Definition bigint.cpp:157
bigint operator-(const bigint &a) const
Definition bigint.cpp:175
BIGNUM * get() const
Definition bigint.hpp:65
bigint & operator++()
Definition bigint.cpp:88
bigint operator/=(const bigint &a)
Definition bigint.cpp:144
int64_t log2() const
Definition bigint.cpp:62
bignum_st BIGNUM
Definition bigint.hpp:7
namespace sysio::chain
Definition authority.cpp:3
std::string string
Definition string.hpp:10
void from_variant(const fc::variant &v, sysio::chain::chain_id_type &cid)
void to_variant(const sysio::chain::shared_public_key &var, fc::variant &vo)
Definition authority.cpp:4
#define value
Definition pkcs11.h:157
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
signed __int64 int64_t
Definition stdint.h:135
unsigned int uint32_t
Definition stdint.h:126
unsigned __int64 uint64_t
Definition stdint.h:136
int l