From f954ff1a255468c81bbbfee37827030aaf3c0132 Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Wed, 14 Aug 2013 01:11:48 -0400 Subject: [PATCH] fix bugs with bigint --- include/fc/crypto/bigint.hpp | 1 + src/crypto/bigint.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) 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();