Bitcoin Forum
December 17, 2017, 07:18:22 AM *
News: Latest stable version of Bitcoin Core: 0.15.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: [Solved]Problem with hashing, public keys and the wiki - Wiki information incomp  (Read 587 times)
Richy_T
Legendary
*
Offline Offline

Activity: 1330


1RichyTrEwPYjZSeAYxeiFBNnKC9UjC5k


View Profile
November 27, 2013, 02:10:51 AM
 #1

EDIT: Nevermind, it looks like hex2bin must be used first. The wiki really needs updating.


So I'm working through the wiki

https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses

I am at this point...

Quote
1 - Take the corresponding public key generated with it (65 bytes, 1 byte 0x04, 32 bytes corresponding to X coordinate, 32 bytes corresponding to Y coordinate)

   0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A 299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6

2 - Perform SHA-256 hashing on the public key

   600FFE422B4E00731A59557A5CCA46CC183944191006324A447BDB2D98D4B408


I got the public key OK, prepended the 04, didn't get the value. Needs an uppercase right? Still no value. So I cut and paste it directly from the page and put it in my code.

Code:
print hash('sha256',"0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6") . "<br>";

Which gives

32511e82d56dcea68eb774094e25bab0f8bdd9bc1eca1ceeda38c7a43aceddce

Which, nicely enough is what I got from the uppercase value I generated so I'm not totally off-base but is not the value listed in the wiki. I'm sure I'm missing something. Can anyone tell me what?

Thanks




1RichyTrEwPYjZSeAYxeiFBNnKC9UjC5k
1513495102
Hero Member
*
Offline Offline

Posts: 1513495102

View Profile Personal Message (Offline)

Ignore
1513495102
Reply with quote  #2

1513495102
Report to moderator
1513495102
Hero Member
*
Offline Offline

Posts: 1513495102

View Profile Personal Message (Offline)

Ignore
1513495102
Reply with quote  #2

1513495102
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1513495102
Hero Member
*
Offline Offline

Posts: 1513495102

View Profile Personal Message (Offline)

Ignore
1513495102
Reply with quote  #2

1513495102
Report to moderator
1513495102
Hero Member
*
Offline Offline

Posts: 1513495102

View Profile Personal Message (Offline)

Ignore
1513495102
Reply with quote  #2

1513495102
Report to moderator
Foxpup
Legendary
*
Offline Offline

Activity: 2044



View Profile
November 27, 2013, 04:34:27 AM
 #2

The wiki really needs updating.
Why? It says "Take the corresponding public key generated with it (65 bytes...)" and "0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A 299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6" is obviously not 65 bytes if you treat it as an ASCII string. Hell, "18E14A7B6A307F426A94F8114701E7C8E774E7F9A47E2C2035DB29A206321725" isn't even a valid private key to start with if treated as ASCII. Wherever hex values are mentioned (not just in the Wiki, but everywhere else on the Internet), it's implied that they're, well, actual hex values, and not an ASCII string.

Will pretend to do unverifiable things (while actually eating an enchilada-style burrito) for bitcoins: 1K6d1EviQKX3SVKjPYmJGyWBb1avbmCFM4
Richy_T
Legendary
*
Offline Offline

Activity: 1330


1RichyTrEwPYjZSeAYxeiFBNnKC9UjC5k


View Profile
November 27, 2013, 05:57:14 AM
 #3

The wiki really needs updating.
Why? It says "Take the corresponding public key generated with it (65 bytes...)" and "0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A 299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6" is obviously not 65 bytes if you treat it as an ASCII string. Hell, "18E14A7B6A307F426A94F8114701E7C8E774E7F9A47E2C2035DB29A206321725" isn't even a valid private key to start with if treated as ASCII. Wherever hex values are mentioned (not just in the Wiki, but everywhere else on the Internet), it's implied that they're, well, actual hex values, and not an ASCII string.

Sure, the hex string represents those bytes but it is ambiguous as to whether you are meant to operate on the string or the bytes themselves. Typically when hex numbers are represented, they'll be written as 0xFFFF notation or FFFFh. If a string, it will be placed in quotes. On the Wiki, neither is the case. Given that other people have had this issue, some clarification would likely not be amiss.

What probably helped throw me off was that my first task was to generate a minikey. For that, you perform the hashing on the string that is the minikey. Now, obviously (I believe) minikeys are a later addition to Bitcoin and shouldn't be looked to for guidance but it did put me in a certain frame of mind. I've also been working with weakly typed languages a lot recently which may have contributed to a certain way of looking at things.

I'll be sharing my code when done so hopefully that will help others.

Edit: Just going back and looking at the wiki page again, I note that the page itself uses 0x notation when referring to bytes in several places. Lack of consistency adds to confusion.

1RichyTrEwPYjZSeAYxeiFBNnKC9UjC5k
Remember remember the 5th of November
Legendary
*
Offline Offline

Activity: 1610

Reverse engineer from time to time


View Profile
November 27, 2013, 07:45:31 AM
 #4

A year ago I faced the same problem. I was operating on the string rather than the bytes.

BTC:1AiCRMxgf1ptVQwx6hDuKMu4f7F27QmJC2
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!