diff --git a/src/crypto/elliptic_secp256k1.cpp b/src/crypto/elliptic_secp256k1.cpp index e71213c..d270b6f 100644 --- a/src/crypto/elliptic_secp256k1.cpp +++ b/src/crypto/elliptic_secp256k1.cpp @@ -49,7 +49,10 @@ namespace fc { namespace ecc { fc::sha256 private_key::get_secret()const { - FC_ASSERT( my->_key != nullptr ); + if( !my->_key ) + { + return fc::sha256(); + } return *my->_key; } diff --git a/tests/ecc_test.cpp b/tests/ecc_test.cpp index 5492d61..df809ee 100644 --- a/tests/ecc_test.cpp +++ b/tests/ecc_test.cpp @@ -68,6 +68,8 @@ int main( int argc, char** argv ) interop_file(argv[2]); } + fc::ecc::private_key nullkey; + for( uint32_t i = 0; i < 3000; ++ i ) { try { @@ -76,6 +78,7 @@ int main( int argc, char** argv ) std::string pass(argv[1]); fc::sha256 h = fc::sha256::hash( pass.c_str(), pass.size() ); fc::ecc::private_key priv = fc::ecc::private_key::generate_from_seed(h); + FC_ASSERT( nullkey != priv ); interop_do(priv.get_secret()); fc::ecc::public_key pub = priv.get_public_key(); interop_do(pub.serialize());