Bitcoin Forum
April 27, 2024, 01:06:51 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: need example Data/Hash1/Midstate/Target for a solved block  (Read 2668 times)
magik (OP)
Newbie
*
Offline Offline

Activity: 44
Merit: 0


View Profile
June 15, 2011, 03:52:54 AM
 #1

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
The trust scores you see are subjective; they will change depending on who you have in your trust list.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
error
Hero Member
*****
Offline Offline

Activity: 588
Merit: 500



View Profile
June 15, 2011, 12:19:46 PM
 #2

Run a miner on testnet and you should have one within a few minutes. Smiley

3KzNGwzRZ6SimWuFAgh4TnXzHpruHMZmV8
Basiley
Newbie
*
Offline Offline

Activity: 42
Merit: 0


View Profile
June 15, 2011, 12:40:20 PM
 #3

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.
etotheipi
Legendary
*
expert
Offline Offline

Activity: 1428
Merit: 1093


Core Armory Developer


View Profile WWW
July 10, 2011, 11:19:19 PM
 #4

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

Founder and CEO of Armory Technologies, Inc.
Armory Bitcoin Wallet: Bringing cold storage to the average user!
Only use Armory software signed by the Armory Offline Signing Key (0x98832223)

Please donate to the Armory project by clicking here!    (or donate directly via 1QBDLYTDFHHZAABYSKGKPWKLSXZWCCJQBX -- yes, it's a real address!)
Sam Rushing
Newbie
*
Offline Offline

Activity: 10
Merit: 0



View Profile WWW
July 10, 2011, 11:35:40 PM
 #5

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 ('<Q', _)
(12112,)
>>> block = db.read_only_file.read (12112)
>>> hexify (dhash (block[:80]))
'2d77d3f929486612f5f72c01fe7ea10e085af995813e9e34bf01000000000000'
>>>
Sam Rushing
Newbie
*
Offline Offline

Activity: 10
Merit: 0



View Profile WWW
July 10, 2011, 11:41:26 PM
 #6

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
etotheipi
Legendary
*
expert
Offline Offline

Activity: 1428
Merit: 1093


Core Armory Developer


View Profile WWW
July 10, 2011, 11:59:14 PM
 #7

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.

Founder and CEO of Armory Technologies, Inc.
Armory Bitcoin Wallet: Bringing cold storage to the average user!
Only use Armory software signed by the Armory Offline Signing Key (0x98832223)

Please donate to the Armory project by clicking here!    (or donate directly via 1QBDLYTDFHHZAABYSKGKPWKLSXZWCCJQBX -- yes, it's a real address!)
Sam Rushing
Newbie
*
Offline Offline

Activity: 10
Merit: 0



View Profile WWW
July 11, 2011, 12:25:05 AM
 #8


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.
Sam Rushing
Newbie
*
Offline Offline

Activity: 10
Merit: 0



View Profile WWW
July 11, 2011, 02:57:22 AM
 #9

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.
etotheipi
Legendary
*
expert
Offline Offline

Activity: 1428
Merit: 1093


Core Armory Developer


View Profile WWW
July 11, 2011, 03:24:25 AM
 #10

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!

Founder and CEO of Armory Technologies, Inc.
Armory Bitcoin Wallet: Bringing cold storage to the average user!
Only use Armory software signed by the Armory Offline Signing Key (0x98832223)

Please donate to the Armory project by clicking here!    (or donate directly via 1QBDLYTDFHHZAABYSKGKPWKLSXZWCCJQBX -- yes, it's a real address!)
Sam Rushing
Newbie
*
Offline Offline

Activity: 10
Merit: 0



View Profile WWW
July 11, 2011, 04:29:15 AM
 #11

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.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!