void convertNonCanonical(std::string const& hex, std::string const& canonHex) { Blob b (loadSignature(hex)); // The signature ought to at least be valid before we begin. expect (isValid (hex), "invalid signature"); size_t len = b.size (); expect (!makeCanonicalECDSASig (&b[0], len), "non-canonical signature was already canonical"); expect (b.size () >= len, "canonicalized signature length longer than non-canonical"); b.resize (len); expect (isCanonicalECDSASig (&b[0], len, ECDSA::strict), "canonicalized signature is not strictly canonical"); Blob canonicalForm (loadSignature (canonHex)); expect (b.size () == canonicalForm.size (), "canonicalized signature doesn't have the expected length"); expect (std::equal (b.begin (), b.end (), canonicalForm.begin ()), "canonicalized signature isn't what we expected"); }
bool RippleAddress::accountPublicVerify (uint256 const& uHash, Blob const& vucSig, ECDSA fullyCanonical) const { CKey ckPublic; bool bVerified = isCanonicalECDSASig (vucSig, fullyCanonical); if (bVerified && !ckPublic.SetPubKey (getAccountPublic ())) { // Bad private key. WriteLog (lsWARNING, RippleAddress) << "accountPublicVerify: Bad private key."; bVerified = false; } else { bVerified = ckPublic.Verify (uHash, vucSig); } return bVerified; }
bool RippleAddress::verifyNodePublic (uint256 const& hash, Blob const& vchSig, ECDSA fullyCanonical) const { CKey pubkey = CKey (); bool bVerified; bVerified = isCanonicalECDSASig (vchSig, fullyCanonical); if (bVerified && !pubkey.SetPubKey (getNodePublic ())) { // Failed to set public key. bVerified = false; } else { bVerified = pubkey.Verify (hash, vchSig); } return bVerified; }
/** Verifies that a signature is syntactically valid and in canonical form. */ bool isStrictlyCanonical (std::string const& hex) { Blob j (loadSignature(hex)); return isCanonicalECDSASig (&j[0], j.size (), ECDSA::strict); }