This discussion is transplanted from the off-topic forum:
It’s the world’s most expensive database, and it’s append-only.
You can always commit some data to r-value of a signature, for no additional cost. Then, it will be committed to your next transaction, whenever it will happen. Or it can be hidden in some unused TapScript branch, even behind OP_RETURN, so it will never be pushed on-chain, but it will still affect address derivation, so it can be later proven to be connected with it.
(Note:
OP_RETURN puts things on-chain, but not in the UTXO set.)
Another way is mining. You already produced
a hash with at least 36 zero bits, so you know some bits can be grinded here and there. Then, you can count, how much space your transactions are taking now, and calculate, how long it would take, to grind things, and save them on-chain, without any additional cost.
Yet another thing is hashing. If you want to store encrypted messages, then you have to write a lot of bytes. However, if you want to just prove, that "you knew X key at Y timestamp", then just committing it to r-value is sufficient, and can be proved later. I think blockchain is more about timestamping, than about pushing actual data, otherwise, we wouldn't have so many pruned nodes.
The way that I ground txid
000000000fdf0c619cd8e0d512c7e2c0da5a5808e60f12f1e0d01522d2986a51 for
the Lauda memorial puzzle was rudimentary. I wrote
my own vanity address generator in 2018; in March 2021, I did a one-off dirty hack on it to grind a change address that produced the desired zeroes in the txid. As you can see on-chain, I later spent the change.
At the time, I
did realize that I could use this method to store data in the txid! I’ve considered writing a wallet which does exactly that, and thought about a protocol for it. If the data are encrypted, this is even a covert channel; is it called “steganography” to hide pseudrandom data in pseudorandom data?
(Up to this point, I’m vaguely aware that although I thought of it independently, the idea is not really original. I believe that much of the below is original.)To avoid losing funds, the change address should be ground according to a well-defined system—say, incrementally tweak what the BIP 32 HD change key
would be for that transaction. Then, disaster recovery of unspent change would have the same computational cost as it took to create the transaction.
Note: I’ve also thought of how to integrate vanity addresses with HD wallets, such that recovering the vanity address private key from seed has the same computational cost as creating the vanity address. If I have good forum experience now, I’ll update Segvan with this as a reference implementation, and draft a BIP. All vanity address generators should use the same system for recoverable keys, and wallets should support easy import via m/x/y/z path plus one extra integer.
This terse note serves as prior art, in case some fucking moron later tries to patent my idea.
Thereupon, I just need to work out a protocol for organizing a wallet’s transactions, such that files can be reconstructed from a few bytes per txid by walking through the transactions created by one HD master key (or a branch of the derivation tree).
Grinding 2 bytes into a txid has a trivial cost. For 4 bytes, it’s a relatively moderate cost. (The 36 bits of zeroes for the puzzle took a
long time, but it was done on four cores of a very old CPU.) If someone makes a GPU implementation, at least another byte or two can be added without much inconvenience.
By thus means, if someone routinely makes Bitcoin transactions, they can slowly archive small, but non-negligible amounts of their most important data on the blockchain—with
no spam and no added tx fees.
athanred, you now gave me the idea for also grinding data into the wtxid, using
r-values. (Or into the txid of a legacy tx, but I don’t want to advocate any continuing non-Segwit usage.) If one starts with a pseudorandom
r-value off
/dev/urandom, then increments it as a 256-bit integer to grind the wtxid, I don’t think this should have any security impact; to be extra-sure, one could simply use a securely-seeded fast stream cipher (Chacha20) to generate pseudo-independent
r-values, until one gets a hit.
For obvious reasons, the txid needs to be ground before the wtxid.
2–4 bytes per txid, 2–4 bytes per wtxid... Every bit adds up!
This thread welcomes all further ideas for harmless, non-spam ways of etching arbitrary data into the blockchain with dual-use transactions. Store arbitrary data on the blockchain, with the transactions that you would make anyway!
Speaking of spam, I see that I missed some awful controversy in the past few years. I am now tempted to put an image file into an
OP_RETURN. It is the tragedy of the commons: When not only the blockchain, but
the UTXO set is bloated with bullshit that does not belong there, why shouldn’t I (ab)use
OP_RETURN for some blockchain art that also makes a sociopolitical statement?
I think I’m actually going to do this, if/when I can spare fee money to carve a pretty picture into Bitcoin forever and forever.
That being said, spammish suggestions are off-topic, and I may delete them accordingly. Moreover,
condoning unspendable UTXO set bloat in this thread will get red trust from me. If you want to store your cat photos on-chain without cleverly working them into financial data,
OP_RETURN or GTFO!