diff --git a/include/fc/crypto/bigint.hpp b/include/fc/crypto/bigint.hpp index e7117ae..e4fdd8b 100644 --- a/include/fc/crypto/bigint.hpp +++ b/include/fc/crypto/bigint.hpp @@ -44,6 +44,7 @@ namespace fc { bigint operator /= ( const bigint& a ); bigint operator *= ( const bigint& a ); bigint& operator += ( const bigint& a ); + bigint& operator -= ( const bigint& a ); bigint& operator <<= ( uint32_t i ); bigint& operator >>= ( uint32_t i ); bigint operator - ( const bigint& a )const; diff --git a/src/crypto/bigint.cpp b/src/crypto/bigint.cpp index d41224c..d13675e 100644 --- a/src/crypto/bigint.cpp +++ b/src/crypto/bigint.cpp @@ -59,7 +59,7 @@ namespace fc { return BN_cmp( n, c.n ) == 0; } bool bigint::operator != ( const bigint& c )const { - return BN_cmp( n, c.n ) == 0; + return BN_cmp( n, c.n ) != 0; } bigint::operator bool()const { @@ -97,6 +97,13 @@ namespace fc { std::swap(*this,tmp); return *this; } + bigint& bigint::operator -= ( const bigint& a ){ + bigint tmp(*this); + BN_sub( tmp.n, n, a.n ); + std::swap(*this,tmp); + return *this; + } + bigint bigint::operator * ( const bigint& a )const { BN_CTX* ctx = BN_CTX_new();