From d9867551fc58ebb62eddef3dfbdb1dc711110577 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Tue, 20 Sep 2011 15:42:36 +0200 Subject: [PATCH] base64-based sign/verify --- src/bitcoinrpc.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 3638adac..c8a0076b 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -561,7 +561,8 @@ Value signmessage(const Array& params, bool fHelp) sres << key.GetPubKey(); // public key sres << vchSig; // signature; - return HexStr(sres.begin(), sres.end()); + vector vchRet(sres.begin(), sres.end()); + return EncodeBase64(&vchRet[0], vchRet.size()); } Value verifymessage(const Array& params, bool fHelp) @@ -579,7 +580,12 @@ Value verifymessage(const Array& params, bool fHelp) if (!addr.IsValid()) throw JSONRPCError(-3, "Invalid address"); - vector vchResult = ParseHex(strSign); + bool fInvalid = false; + vector vchResult = DecodeBase64(strSign.c_str(), &fInvalid); + + if (fInvalid) + throw JSONRPCError(-5, "Malformed base64 encoding"); + CDataStream sres(vchResult); std::vector vchPubKey;