## How can one embed custom data in block headers?

20

4

Some mining pool admins put custom data in block headers, like prayers. How do they do that? Where can I see that data for myself?

fair enough, can we now get one high-level answer that clarifies there are (at least) two ways that people have put messages and other custom data into the block chain? – lemonginger – 2011-09-14T22:54:25.797

1You can't embed ANYTHING in the block header. You can embed data in the block itself. The two methods are via the coinbase transaction or via a "dummy transaction". Neither of which put anything in the block header. – DeathAndTaxes – 2011-10-25T14:13:24.510

People have written messages in the blockchain using http://etchablock.com/ - see http://blockexplorer.com/tx/237b50dac42af130171773b233954e62690182fd4901a453ad5d11d1d54a8ca3 for an example.

– Chris Moore – 2012-02-12T07:00:40.817

17

When you generate a block, the generation transaction (the one that creates new coins) has an attribute called coinbase. It's a special value you can put anything you want in to make the block unpredictable to others (and this is good).

So, naturally, you can put text in this attribute, although most just put mining-related information that is not human-readable (nonce and extra-nonce).

You can read this coinbase by using a patched bitcoin node that can dump blocks, for example with the "dumpblock" or "getblockbyhash" patches.

Or you can just print every string in the blockchain database directly : strings -n 20 blk0001.dat

Example for the 1st block:

Coinbase: 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73

ASCII-translation: ᝣᝣᝣᝣᝣᝣᝣEThe Times 03/Jan/2009 Chancellor on brink of second bailout for banks

This is what is used by the Eligius pool ; it puts prayers in this field.

Actually, that's not the most efficient way to store information in the blockchain. See my comment. – Mononofu – 2011-08-30T21:30:30.133

That http://pident.artefact2.com/b/0 link is dead. It tells me "[...] is no longer available on this server and there is no forwarding address. Please remove all references to this resource."

– Chris Moore – 2012-02-17T19:38:53.623

True, it may not be the most efficient way, but it definitely is the easiest way (both for putting messages and reading them). – Artefact2 – 2011-08-30T21:34:08.943

7

Dan Kaminsky explained his method and motivations for inserting images into the blockchain at a talk at Black Hat USA 2011 - the relevant slides (12 -20) from the presentation can be found here.

His basic method was to create transactions with lots of outputs and to include the message in ASCII, in pieces, in the receiving address field of the output scripts. You can see the corresponding hex codes for the ASCII in his message in the raw transaction. You can see that the message is interrupted by the other transaction fields, so you can only see the messages properly if you look with a tool (such as strings) that filters out non-printable characters and displays printable characters in lines. His transaction required a .15 bitcoin fee, about \$1.50 at the time.

Can you provide a little bit of info in the answer besides the link? – ripper234 – 2011-09-02T06:53:59.070

yes a slight explanation of the method used would be great. – lemonginger – 2011-09-03T04:30:58.057

5

There was a very interesting talk at Chaos Communication Camp this year on this topic. IIRC, you can store arbitrary information in bitcoin transactions, since they actually contain "programs" specifying how the transaction should be verified.

Information on the 'scripting' interface can be found here. See section 2.3 for details on imbedding messages.

The question is about embedding data in block headers, not about transactions. – nmat – 2011-08-31T01:02:20.933

6@nmat: Well, if you're going to take it literally, then the answer is that you can't. At least, not by any means that are remotely practical. (The header is too small and most of the fields are compelled.) – David Schwartz – 2011-08-31T10:22:05.003

-2

The hacker was Dan Kaminsky, and he embedded this image in the blockchain.

This is right now just a technological curiosity, it has no known implication on the legal or technical aspects of Bitcoin. I haven't read his paper, but he must have used a modified miner that searches for hashes that begin with a preset prefix.

Let's clarify: Mining is the process of finding solutions (or hashes) to a cryptography equation. The first to find a solution gets to have his solution added to the blockchain - the permanent transaction record. What Kaminsky did was look for a particular kind of hash instead of just any random hash, that contains the embedded test. Once this was found (just a matter of running a miner for a long enough period), this specific solution, with the embedded text, was added to the blockchain.

I think so. I actually didn't understand how that worked myself :) – lemonginger – 2011-08-31T00:02:59.003

Are you sure about this? According to this he did it using transactions with special destination addresses

– nmat – 2011-08-31T00:40:28.830

1@nmat - not sure at all, I had assumed this was how it was done. (Mother of all ****ups). Please post another answer. – ripper234 – 2011-08-31T00:43:08.267

yes someone please post another answer, this is definitely incorrect. – lemonginger – 2011-09-01T22:40:16.883

can you write a sentence or two about what that means (ie; how does one embed an image in a list of transactions). trying to get an answer here that shows no one had access to the blockchain to "change transaction data" or something similar. – lemonginger – 2011-08-30T23:49:22.027

@lemoginger - does my extended answer answer your question? – ripper234 – 2011-08-30T23:55:05.940