Hi Chris,
I was able to work out how to get valid results from the test cases you
gave (it was a merry chase through the sample code snippets though). I
wound up comparing the available C# fragments to the BitcoinJ library
(which most of the C# examples appear to be based on), and adding the
missing bits. Essentially it boils down to formatting the input message
correctly, and also encoding the Q value correctly (as input to the
hashes) when the lead byte of the signature specifies compression.

Also there were was a potential problem in the way the point R was
decoded (from compressed format) which I've fixed up, though it may not
affect these particular cases. Likewise I've lifted the calculation of
'e' from the BC ECDSA implementation, since what was there was iffy.

Code is added as answer on stackoverflow
(http://stackoverflow.com/a/20000007/328397). I didn't bother with the
Base58 part, but if you plug in the RIPEMD_160 output that
CheckSignedMessage produces, into the test website
(http://gobittest.appspot.com/Address), it recovers the correct Base58
value.

Regards,
Pete Dettman


On 5/12/2013 1:02 AM, Mankowski, Chris wrote:
>
> Resending on a PC… Outlook for OSX gave me the funny font. Apologies
> to all who can’t stand Comic Sans-like rendering on a PC
>
> Hello,
>
> The Bitcoin QT client allows me to sign a message, and extract a
> public key from that signature itself. I am supposed to then hash this
> signature in Base58Checked format and then extract the key.
>
> The code to extract the key from a signature is here
>
> http://stackoverflow.com/a/20000007/328397
>
> The code to get the Base58 address is on the same page, or just paste
> the extracted public key here: http://gobittest.appspot.com/Address
>
> Since I know the Base58Checked encoder works as intended, and it
> appears the key extraction code works as well, I suspect it may be how
> I知presenting the Endian that I知presenting Q to the hash utility, or
> even an encoding bug,
>
> Here are some tests from the Bitcoin QT client that produce valid
> results in the client, but I can稚get it to work in C#:
>
> Sig
> ICHD2obqklY8dVBvjwwiDL3c7QkOnOif0tRlbcM+uk7vnuA0LZu6mVsKMx3Nvk7vdiV28cHO7IRuqXwzO3A3m3A=
>
> Message test123
>
> Hashed Public key - 15NGbNHePvuxKJrSV7Qy7Z9pKjxJDo39nV
>
> Sig:
> IEMtA9uGW2x70/qxAaPuE4Fb/H5+Dq+bl0UyMHZXoO7SX4vfXQcg22VafERUMTT5AfpXbTesAk5NSYnPVYulrTM=
>
> Message test123
>
> Hashed Public Key - 191FLr28ee3ahg3yDJDLzoS9jfjUvDouzL
>
> Any assistance would be appreciated.
>
>

Reply via email to