Author

Topic: need example Data/Hash1/Midstate/Target for a solved block (Read 2686 times)

newbie
Activity: 10
Merit: 0
You, sir, deserve 0.7 BTC!  0.5 for the bounty and a tip for providing lots of great reference code. 
Much appreciated.  This is an independent project for the time being, so every donation helps convince my wife I'm not wasting my time! 8^)  [BTW the donation address is at the top of the README]

Quote
A request:  please add and commit that to your git repo so that it is easier for others to find in the future.  That will be most helpful! 
I'll put a link to it in the README... I'd prefer to keep the code itself free of any distractions.  Something like it should go into unit tests when someone gets around to writing some. 8^)

Quote
By the way, did you just make up that block?  What block has only 3 transactions?  And lastly, when you say "reversed", are you really just talking about switching the byte order to little-endian?  Or is this is a different kind of reversal?

Nah, I just clicked a few blocks back in the block browser (try http://localhost:8380/admin/) until I found one small enough to include in the file.

The hash strings as seen on block explorer are byte-reversed.  I think it's because the bitcoin authors think of hashes as (litte-endian) numbers.  I tend to think of hashes as strings (since every hash library does), and like to keep them oriented as I'd see them on the wire.  Less confusing IMHO.

legendary
Activity: 1428
Merit: 1093
Core Armory Developer
You, sir, deserve 0.7 BTC!  0.5 for the bounty and a tip for providing lots of great reference code.  A request:  please add and commit that to your git repo so that it is easier for others to find in the future.  That will be most helpful! 

By the way, did you just make up that block?  What block has only 3 transactions?  And lastly, when you say "reversed", are you really just talking about switching the byte order to little-endian?  Or is this is a different kind of reversal?

Thanks again!
newbie
Activity: 10
Merit: 0
This quick demo takes apart a sample block and its transactions, and computes the block header hash:

http://dark.nightmare.com/rushing/python/bitcoin_hash_test.py

The sample block (embedded, #135687) has three transactions.
newbie
Activity: 10
Merit: 0

It looks like you're part of the way there.  Is it possible for you to put the data into binary files, exactly as it would appear in a getheaders/getdata reply?  I think someone should be able to download the files into a "UnitTest" directory, and be able to check that their code successfully reads and verifies the hashes and signatures, without having to organize the various CLI commands you listed below.  Any associated text file should simply clarify what data is there, in case the person is having trouble getting things to work.

I might put something like this together later tonight.  Watch this space.

Quote
And thanks for the link to your github project.  It looks like it will be a really useful reference, since I'm developing my own python implementation.  Or maybe I should just use yours as a starting point...?  I started from the pybitcoin code that is a year old, assuming I would get a great lesson in BTC in the process of updating it.  But, it's been a little overwhelming so far...

You're certainly welcome to use my code.  I'll probably end up using it in one or more scalable servers on the public internet rather than an end-user client.  That's one reason I'm not concerned so much with NAT/firewall issues.

Quote
P.S. - you mention in your README that it will work with any crypto library -- you might consider using M2Crypto.  It should have everything anyone would need for bitcoin, combined with hashlib.

Yup.  I'm not a fan of openssl - I view it as one big security hole in the entire system.  Luckily there's no ASN1 going over the wire. Still, it should be pretty easy to make an m2crypto version of ecdsa_xxx.py.  For my own personal use I'd rather use a high-performance pure-crypto library.  Unfortunately the one candidate I found does not implement EC.
legendary
Activity: 1428
Merit: 1093
Core Armory Developer
Sam,

It looks like you're part of the way there.  Is it possible for you to put the data into binary files, exactly as it would appear in a getheaders/getdata reply?  I think someone should be able to download the files into a "UnitTest" directory, and be able to check that their code successfully reads and verifies the hashes and signatures, without having to organize the various CLI commands you listed below.  Any associated text file should simply clarify what data is there, in case the person is having trouble getting things to work.

And thanks for the link to your github project.  It looks like it will be a really useful reference, since I'm developing my own python implementation.  Or maybe I should just use yours as a starting point...?  I started from the pybitcoin code that is a year old, assuming I would get a great lesson in BTC in the process of updating it.  But, it's been a little overwhelming so far...

Thanks,
-Eto

P.S. - you mention in your README that it will work with any crypto library -- you might consider using M2Crypto.  It should have everything anyone would need for bitcoin, combined with hashlib.
newbie
Activity: 10
Merit: 0
Oh, and to address the specific request for an actual block header and signature:

>>> block[:80]
'\x01\x00\x00\x00\x06X\xd3\xaca\xbbV\xff\xa2\x9ch\xa1\xf6m\xf5\xf4e\xe37)\xd3o\x02\xee,\t\x00\x00\x00\x00\x00\x00/$\xe6\xaa\xf9BZ\x1e\x0ewPm\xcf\x19B0\x1d\x8c\xfc\xabY\xd1\xf8\x06\xe1)\xb8\xfe\xd5]\xf7\xbb\xa2(\x14N\x12*\x0c\x1a7\x14\x03\xc5'
>>> dhash (_)
'-w\xd3\xf9)Hf\x12\xf5\xf7,\x01\xfe~\xa1\x0e\x08Z\xf9\x95\x81>\x9e4\xbf\x01\x00\x00\x00\x00\x00\x00'
>>> hexify (_)
'2d77d3f929486612f5f72c01fe7ea10e085af995813e9e34bf01000000000000'
>>>


dhash is just double-sha256: https://github.com/samrushing/caesure/blob/master/bitcoin.py#L61
newbie
Activity: 10
Merit: 0
Try my python client out.  Getting copies of blocks from the official client is easy, and everything is stored in a very simple flat file.
It's also easy to instrument the code to see exactly how it all works (or step through it using the python debugger).

$ git clone git://github.com/samrushing/caesure.git

https://github.com/samrushing/caesure

$ python -i bitcoin.py 
reading block headers...
last block (135676): 00000000000001f70a341ab7eb1e5d7a1d01645133abb93df3eb29f8044c28eb
>>> db['00000000000001f70a341ab7eb1e5d7a1d01645133abb93df3eb29f8044c28eb']
<__main__.BLOCK instance at 0x3f15968>
>>> b = _
>>> b.transactions[1].dump()
hash: 01de4dfc338b41b6f6627761fbf2643097af4a3dd187569905f0a4212cc51228
inputs: 1
  0 209701b2126475f7ba2ec6614e4c72b07d6cba94dd0f150003a1daf271a8a892:0 47304402202c0ef7a47f36a3276bc5c95ac09ce26f318ae3eff140dc35af88eb0a35b455ca02205 b2ce9da7a60a25dfddfcc3f571c78c50934d16d9c3c4e59204ef3cc365bcb2301 4294967295
1 outputs
  0 50.12960000 1CxjYUcBFmBftskGFST9MXhyQMQUNTuBzi
lock_time: 0
>>> pos = db.blocks[db.num_block[135000]]
>>> pos
355084932L
>>> db.read_only_file.seek (pos)
>>> db.read_only_file.read (Cool
'P/\x00\x00\x00\x00\x00\x00'
>>> import struct
>>> struct.unpack ('(12112,)
>>> block = db.read_only_file.read (12112)
>>> hexify (dhash (block[:80]))
'2d77d3f929486612f5f72c01fe7ea10e085af995813e9e34bf01000000000000'
>>>
legendary
Activity: 1428
Merit: 1093
Core Armory Developer
I second this request.  As someone working on developing a new client, having an example block would be extraordinarily useful as a verification unit test for all the crypto/hashing code.  The mixed endian-ness and multiple-hashings are extremely confusing and easy mess up.   This kind of thing exists for all crypto algorithms, usually found on their wiki page (look at the SHA-2 wiki page).  BTC client development would be a lot easier with a full example listed somewhere.

Yes, I should be able to use tcpdump or wireshark, but I don't have it or know how to use it.  And even if I did, I'm not confident I pulled the data correctly and what form the bits are in.  How do I know if the nonce is listed in little-endian or big-endian, since it could be either.  

*** BOUNTY 0.5 BTC ***

Since some people do consider this task to be easy, I'm sure someone would be willing to do it for 0.5 BTC.  This is what I want:

(BINARY FILE)  Any block header with resulting hash
(BINARY FILE)  The block data for that header
(TEXT FILE)   ID the header fields, and the human-readable form of those fields (hexdigests/integers/base58 values of hashes/numbers/keys/addresses/etc)
(TEXT FILE)   Explain the block data -- number of transactions, and the human-readable components of the first and second transaction in the block (one coinbase, one regular)

Between these four files, I will get an example of a full public key, private key signature, script bits, base58 address, transaction hash, merkle root, block hashes, and any other common bit representation.  Where multiple representations are possible, it would be nice to see all of them.  Preferably, these four files can be posted to the bitcoin wiki, and the wiki page for bitcoin.  Perhaps OP will offer 0.5 BTC too!

Thanks,
-Eto
newbie
Activity: 42
Merit: 0
I've been writing some code to do the SHA-256 block finding algorithm, but it'd be nice to have some real data to make sure the code works.

Can anyone supply some old data of an already solved block?  The data/hash1/midstate/target etc from the 'getwork' RPC call, and the nonce that solves it.

Probably a stretch here the newbie zone... but worth a post/try
what for ?
replay/mitm attack ?
you can use tcpdump/wireshark combo to watch own BTC client chit-chat with BTC network to get it.
hero member
Activity: 588
Merit: 500
Run a miner on testnet and you should have one within a few minutes. Smiley
newbie
Activity: 44
Merit: 0
I've been writing some code to do the SHA-256 block finding algorithm, but it'd be nice to have some real data to make sure the code works.

Can anyone supply some old data of an already solved block?  The data/hash1/midstate/target etc from the 'getwork' RPC call, and the nonce that solves it.

Probably a stretch here the newbie zone... but worth a post/try
Jump to: