<p>Yes, but with some very strict limitations.</p>

<ol>
<li><p>You can store encrypted data in the block chain.  This is expensive, hard, and strongly discouraged, but it is possible to place the encrypted data in nulldata (OP_RETURN) transactions.  Each standard OP_RETURN output is limited to an 80 byte payload, so you'll probably need to use multiple outputs which will require multiple transactions unless you have the help of a miner.</p></li>
<li><p>A later transaction can publicly disclose the key to the encrypted data.  You can use a smart contract (specifically a <a href="https://en.bitcoin.it/wiki/Hashlock" rel="nofollow noreferrer">hashlock</a>) to pay someone to release the key.  A clever use of cryptography may be able to restrict them from releasing the keys except under certain circumstances; for example Peter Todd's <a href="https://github.com/petertodd/timelock" rel="nofollow noreferrer">timelocks</a> can restrict the public release of the key by number of CPU hours spent generating the decryption key.</p></li>
</ol>

<p>The essential piece of information here is that you can't make the key release mechanism part of a smart contract because the key would need to be public.  At best you can only use a smart contract to incentivize someone who already has a key (or the ability to regenerate a key) to publicly release that key when the incentives are worth it.</p>

<p>With that said, it's probably much better in most cases to put your encrypted data in a torrent file rather than the block chain, and at most use a Bitcoin hashlock to incentivize anyone with the decryption key to release it.  (It'd be nice if you also made the hashlock an anyone-can-spend after an expiration time so that it wouldn't bloat the UTXO set forever if the decryption key was permanently lost.)</p>

CC BY-SA 3.0
2017-10-18T13:52:29.300Z
2017-10-18T13:52:29.300Z
David A. Harding
<p>No, you can't.</p>

<p>There is no secret information <em>anywhere</em> in a blockchain. It is exactly the log of all information the public has to verify correctness of the system.</p>

CC BY-SA 3.0
2017-10-18T12:38:00.757Z
2017-10-18T12:38:00.757Z
Pieter Wuille
<p>Is it possible to store an encrypted message in the blockchain that reveals itself only when a particular condition is met? </p>

<p>I think that the conditional disclosure can be done with <em>Smart Contracts</em>, but I don’t know if it would be securely encrypted until the condition to disclosure is met.</p>

<encryption><smartcontracts>
Conditional based Crypto based on Smart Contracts
Francesco Cerofolini
# Conditional based Crypto based on Smart Contracts

(Asked by: username_0 on 2017-10-17)

Is it possible to store an encrypted message in the blockchain that reveals itself only when a particular condition is met?

I think that the conditional disclosure can be done with *Smart Contracts*, but I don’t know if it would be securely encrypted until the condition to disclosure is met.

**Tags:** encryption, smartcontracts


---

## 2 answers

### Answer by username_1 on 2017-10-18. Score: 2

Yes, but with some very strict limitations.

1. You can store encrypted data in the block chain. This is expensive, hard, and strongly discouraged, but it is possible to place the encrypted data in nulldata (OP\_RETURN) transactions. Each standard OP\_RETURN output is limited to an 80 byte payload, so you'll probably need to use multiple outputs which will require multiple transactions unless you have the help of a miner.
2. A later transaction can publicly disclose the key to the encrypted data. You can use a smart contract (specifically a [hashlock](https://en.bitcoin.it/wiki/Hashlock)) to pay someone to release the key. A clever use of cryptography may be able to restrict them from releasing the keys except under certain circumstances; for example Peter Todd's [timelocks](https://github.com/petertodd/timelock) can restrict the public release of the key by number of CPU hours spent generating the decryption key.

The essential piece of information here is that you can't make the key release mechanism part of a smart contract because the key would need to be public. At best you can only use a smart contract to incentivize someone who already has a key (or the ability to regenerate a key) to publicly release that key when the incentives are worth it.

With that said, it's probably much better in most cases to put your encrypted data in a torrent file rather than the block chain, and at most use a Bitcoin hashlock to incentivize anyone with the decryption key to release it. (It'd be nice if you also made the hashlock an anyone-can-spend after an expiration time so that it wouldn't bloat the UTXO set forever if the decryption key was permanently lost.)


---

### Answer by username_2 on 2017-10-18. Score: 1

No, you can't.

There is no secret information *anywhere* in a blockchain. It is exactly the log of all information the public has to verify correctness of the system.


---

