From eaa763aff18e0c8c52e093ae9850a216a98ab435 Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Fri, 11 Mar 2016 12:33:33 -0500 Subject: [PATCH] adding canonical flag --- include/fc/crypto/elliptic.hpp | 2 +- src/crypto/elliptic_impl_priv.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/fc/crypto/elliptic.hpp b/include/fc/crypto/elliptic.hpp index 99cd68a..dd60da7 100644 --- a/include/fc/crypto/elliptic.hpp +++ b/include/fc/crypto/elliptic.hpp @@ -123,7 +123,7 @@ namespace fc { fc::sha512 get_shared_secret( const public_key& pub )const; // signature sign( const fc::sha256& digest )const; - compact_signature sign_compact( const fc::sha256& digest )const; + compact_signature sign_compact( const fc::sha256& digest, bool require_canonical = true )const; // bool verify( const fc::sha256& digest, const signature& sig ); public_key get_public_key()const; diff --git a/src/crypto/elliptic_impl_priv.cpp b/src/crypto/elliptic_impl_priv.cpp index ad79ebe..585ffde 100644 --- a/src/crypto/elliptic_impl_priv.cpp +++ b/src/crypto/elliptic_impl_priv.cpp @@ -85,7 +85,7 @@ namespace fc { namespace ecc { return secp256k1_nonce_function_default( nonce32, msg32, key32, *extra, nullptr ); } - compact_signature private_key::sign_compact( const fc::sha256& digest )const + compact_signature private_key::sign_compact( const fc::sha256& digest, bool require_canonical )const { FC_ASSERT( my->_key != empty_priv ); compact_signature result; @@ -94,7 +94,7 @@ namespace fc { namespace ecc { do { FC_ASSERT( secp256k1_ecdsa_sign_compact( detail::_get_context(), (unsigned char*) digest.data(), (unsigned char*) result.begin() + 1, (unsigned char*) my->_key.data(), extended_nonce_function, &counter, &recid )); - } while( !public_key::is_canonical( result ) ); + } while( require_canonical && !public_key::is_canonical( result ) ); result.begin()[0] = 27 + 4 + recid; return result; }