Browse Source

numbers to words

cl-refactor
subtly 10 years ago
parent
commit
5fc22a8cc7
  1. 7
      libdevcrypto/EC.cpp

7
libdevcrypto/EC.cpp

@ -86,14 +86,15 @@ Signature crypto::sign(Secret const& _k, bytesConstRef _message)
bool crypto::verify(Public _p, Signature _sig, bytesConstRef _message, bool _raw) bool crypto::verify(Public _p, Signature _sig, bytesConstRef _message, bool _raw)
{ {
static size_t derMaxEncodingLength = 72;
if (_raw) if (_raw)
{ {
assert(_message.size() == 32); assert(_message.size() == 32);
byte encpub[65] = {0x04}; byte encpub[65] = {0x04};
memcpy(&encpub[1], _p.data(), 64); memcpy(&encpub[1], _p.data(), 64);
byte dersig[72]; byte dersig[derMaxEncodingLength];
size_t cssz = DSAConvertSignatureFormat(dersig, 72, DSA_DER, _sig.data(), 64, DSA_P1363); size_t cssz = DSAConvertSignatureFormat(dersig, derMaxEncodingLength, DSA_DER, _sig.data(), 64, DSA_P1363);
assert(cssz <= 72); assert(cssz <= derMaxEncodingLength);
return (1 == secp256k1_ecdsa_verify(_message.data(), _message.size(), dersig, cssz, encpub, 65)); return (1 == secp256k1_ecdsa_verify(_message.data(), _message.size(), dersig, cssz, encpub, 65));
} }

Loading…
Cancel
Save