Title: verifying hashes using sha256sum Post by: genjix on February 15, 2011, 01:27:37 AM http://blockexplorer.com/rawblock/00000000000271de9d8b94afff543366e290e995f3e3e337bb86a0b7bf02e8d1
Take this as an example. Bitcoin is little endian, right? So we need: 4 bytes - version 32 bytes - previous block hash 32 bytes - merkle root number 4 bytes - 4 second periodic timestamp (is it unix time?) 4 bytes - bits for difficulty 4 bytes - random nonce 1 byte - 0 From blockexplorer what values would I need to pickle into the file? version - 1 prev hash - 00000000000148c04e58dca8e1a2df251339c81e2dfe1ff0e9d655b7b4ca428d merkle root - 72febc107470c4f83e224f9683a5c7fb24c4dece8412b9d95db277c8dd75451d timestamp - 1297566305 "bits" - 1b028552 nonce - 329961997 0 So I would write these to a file in binary little endian format then run: sha256sum -b block_header > output sha256sum -b output and that should give 000000000001b85fa1709c6824d19d5c7d20736b0b2ea5fd470705a9513c42ae right? and how is 'version' decided? do new bitcoin versions up that number and fork the blockchain while accepting version 1 from before a certain point? Title: Re: verifying hashes using sha256sum Post by: theymos on February 15, 2011, 01:29:01 AM I believe all the hashes need to be reversed in some way.
The correct version and timestamp values are shown in rawblock: http://blockexplorer.com/rawblock/00000000000271de9d8b94afff543366e290e995f3e3e337bb86a0b7bf02e8d1 Version is always 1, and timestamp is the Unix timestamp. Title: Re: verifying hashes using sha256sum Post by: dirtyfilthy on February 15, 2011, 01:44:24 AM I've already said this on irc, but for anybody else reading along don't include the transaction count when hashing i.e. no zero at the end, just finish on the nonce
Title: Re: verifying hashes using sha256sum Post by: pla on February 20, 2011, 11:26:31 PM From blockexplorer what values would I need to pickle into the file? Did you ever find a solution to this? I tried the following: Code: #include<stdio.h> (Dat1 has the values as they appear from blockexplorer, Dat2 has them bytewise-reversed - And spare me the comments about error handling ;) ). Neither produces the "right" hash via sha256sum. Perhaps relevant, I notice that the "data" field from running "bitcoind getwork" has another 12 dwords worth of crap after the nonce, all zeros except for the 1st and 12th. That pads it to 128 bytes (not coincidentally, the value of that first dword after the nonce), but I see no particular reason why it contains anything after the nonce. Title: Re: verifying hashes using sha256sum Post by: Hal on February 21, 2011, 01:30:52 AM sha256sum produces hex output, you need to convert to binary with xxd:
sha256sum -b manual.txt | colrm 65 99 | xxd -r -p | sha256sum -b d1e802bfb7a086bb37e3e3f395e990e2663354ffaf948b9dde71020000000000 Title: Re: verifying hashes using sha256sum Post by: Lis on April 28, 2011, 06:29:54 AM sha256sum produces hex output, you need to convert to binary with xxd: please show the contents of the file manual.txtsha256sum -b manual.txt | colrm 65 99 | xxd -r -p | sha256sum -b d1e802bfb7a086bb37e3e3f395e990e2663354ffaf948b9dde71020000000000 Title: Re: verifying hashes using sha256sum Post by: riX on May 01, 2011, 02:18:42 AM please show the contents of the file manual.txt Code: echo 010000008d42cab4b755d6e9f01ffe2d1ec8391325dfa2e1a8dc584ec0480100000000001d4575ddc877b25dd9b91284cedec424fbc7a583964f223ef8c4707410bcfe72614a574d5285021b0dd2aa13 | xxd -r -p> manual.txt Title: Re: verifying hashes using sha256sum Post by: Lis on May 04, 2011, 07:24:44 AM please show the contents of the file manual.txt Code: echo 010000008d42cab4b755d6e9f01ffe2d1ec8391325dfa2e1a8dc584ec0480100000000001d4575ddc877b25dd9b91284cedec424fbc7a583964f223ef8c4707410bcfe72614a574d5285021b0dd2aa13 | xxd -r -p> manual.txt Title: Re: verifying hashes using sha256sum Post by: Bablos on July 29, 2011, 02:00:40 PM My simple program for bitcoins getwork checking responce (based on sha256sum source code):
rescheck.zip (http://narod.ru/disk/20376221001/rescheck.zip.html) (7.59kB). To build use: Code: $ gcc -O3 -o rescheck sha256.c rescheck.c Facility:
For example: Code: ./rescheck 010000008d42cab4b755d6e9f01ffe2d1ec8391325dfa2e1a8dc584ec0480100000000001d4575ddc877b25dd9b91284cedec424fbc7a583964f223ef8c4707410bcfe72614a574d5285021b0dd2aa13 Code: $./rescheck 010000008d42cab4b755d6e9f01ffe2d1ec8391325dfa2e1a8dc584ec0480100000000001d4575ddc877b25dd9b91284cedec424fbc7a583964f223ef8c4707410bcfe72614a574d5285021b0dd2aa13 \ Code: $./rescheck 0000000133d3ca51635c3df04ed4420695184cc3b15a418c1d38e0af004644840000000048b034d304884865b81968d57620cf223b1000f91294b1bcab895dc0ab43a7a84e0896081b6f24bb64f3f0fe00000080000 |