<p>If I've understood correctly, I don't think you need block-chain technology to achieve what you want. This is exactly what asymmetric public key encryption is designed for. </p>

<p>A simply encrypts some information using A's private key and B's public key... thereby ensuring:</p>

<ul>
<li>Only B can decrypt the information </li>
<li>B can verify the information was
encrypted by A (using A's public key)</li>
</ul>

<p>There's no way for A to prove to B that their copy of the information has been destroyed or forgotten by A, but at least secure transmission is ensured.</p>

CC BY-SA 3.0
2018-01-26T08:25:42.463Z
I totally agree that's the purpose of asymmetric encryption, my question was more about the practical way of doing it using existing blockchain mechanism, in ethereum or others. Can a contract do this?
tomsoft
CC BY-SA 3.0
2018-02-24T18:25:15.647Z
There is nothing practical about forcing the entire world to see and store your data, as opposed to just giving it to who needs it.
Pieter Wuille
CC BY-SA 3.0
2017-11-25T15:56:39.227Z
2017-11-25T15:56:39.227Z
James Crosswell
<p>(Even though i'm on the bitcoin.stackexchange side this came up with an Ethereum tag so i'll answer from the Ethereum perspective)</p>

<p>Short answer is: Yes it is entirely possible. Using asymetric public key encryption as James mentioned. It is however also entirely non-economical. </p>

<p>Some new, different, private/public chains have been specifically designed to handle data storage on-chain because current chains like Ethereum, make it cost prohibitive. As the amount of data you seek to store increases, the amount of effort to "mine" the transaction (with the data you want to store) also increases. That is why network fee's are calculate at a Byte rate. </p>

<p>Check out Tjaden's answer here: <a href="https://ethereum.stackexchange.com/questions/872/what-is-the-cost-to-store-1kb-10kb-100kb-worth-of-data-into-the-ethereum-block">https://ethereum.stackexchange.com/questions/872/what-is-the-cost-to-store-1kb-10kb-100kb-worth-of-data-into-the-ethereum-block</a> </p>

<p>My best attempt at answering the "smart contract to simplify" aspect would be </p>

<ol>
<li>Already knowing the decryption key</li>
</ol>

<p>or</p>

<ol start="2">
<li>Being able to decrypt data in a smart contract to get the decryption key. </li>
</ol>

<p>In '2' you'd have a smart contract that would accept transactions with a set decryption. Every time A wanted to send a message that B could read, it would submit an encrypted, decryption key. B would have to find the transaction, decrypt the key, then use that key to decrypt the message. It's more like 2-auth but for an encrypted payload. </p>

<p>This would not be elegant or efficient. There are better ways to accomplish the same task.</p>

CC BY-SA 4.0
2018-12-17T21:51:10.137Z
2018-12-17T21:51:10.137Z
cleanmarker
<p>I don't really understand what you are trying to do:</p>

<ul>
<li>If you want to prove that party A (and later party B) owns something, you can use a similar design as Bitcoin. Where bitcoins are send around by transactions where the "current holder" signs a message saying the bitcoins now belong to "a new holder".</li>
<li>If you have a special smart contract which only the "current owner" is allowed to use and you want to pass ownership around more flexible. You can create another smart contract that holds "the current owner" in a more flexible way. See identity contracts in uPort.</li>
<li>If party A wants to give some data party B (but no one else), why would you use a blockchain at all?</li>
</ul>

<p>Could you more clearly specify what you mean with:</p>

<blockquote>
  <p>and want to give the ownership of this data to B</p>
</blockquote>

<p>In the blockchain world you just store this in the "ledger" (or blockchain), exactly the same as what bitcoin does.</p>

CC BY-SA 3.0
2017-07-28T09:34:35.457Z
2017-07-28T09:34:35.457Z
askmike
<p>Following my previous question on this topic <a href="https://bitcoin.stackexchange.com/questions/52064/is-there-a-way-to-store-and-share-a-private-key-through-blockchain">Is there a way to store and share a private key through blockchain?</a>, I might have a solution but I would like to improve the process.</p>

<p>Image that A is the owner of some private data, and want to give the ownership of this data to B, another member of the blockchain. The data is a private key so it can not be public, but it can be encoded using A or B public key.</p>

<p>So:</p>

<ul>
<li>Secret data is encoded with A public key, and stored in A informations data /</li>
<li>B want to by A secret data</li>
<li>A decode the secret data (using his private wallet key) and encode the secret data with B public key</li>
<li>Ownership of the data is given to B</li>
<li>Now only B (and A also but that's a different story) can decode secret data.</li>
</ul>

<p>Is there a way to simplify this process using smart contract? I assume a smart contract have access to A and B public key, but can a data be encoded/decoded with private key of the one executing the smart contract?</p>

CC BY-SA 3.0
2017-11-22T12:42:22.883Z
I’ve been thinking about this too. Have you found some kind of mechanism to at least partially do this?
el-flor
<ethereum><smartcontracts>
How to store private data in blockchain and smart contract
tomsoft
# How to store private data in blockchain and smart contract

(Asked by: username_0 on 2017-07-28)

Following my previous question on this topic [Is there a way to store and share a private key through blockchain?](https://bitcoin.stackexchange.com/questions/52064/is-there-a-way-to-store-and-share-a-private-key-through-blockchain), I might have a solution but I would like to improve the process.

Image that A is the owner of some private data, and want to give the ownership of this data to B, another member of the blockchain. The data is a private key so it can not be public, but it can be encoded using A or B public key.

So:

* Secret data is encoded with A public key, and stored in A informations data /
* B want to by A secret data
* A decode the secret data (using his private wallet key) and encode the secret data with B public key
* Ownership of the data is given to B
* Now only B (and A also but that's a different story) can decode secret data.

Is there a way to simplify this process using smart contract? I assume a smart contract have access to A and B public key, but can a data be encoded/decoded with private key of the one executing the smart contract?

**Tags:** ethereum, smartcontracts

> **Comments:**
> **username_1**: I’ve been thinking about this too. Have you found some kind of mechanism to at least partially do this?  

---

## 3 answers

### Answer by username_2 on 2017-11-25. Score: 2

If I've understood correctly, I don't think you need block-chain technology to achieve what you want. This is exactly what asymmetric public key encryption is designed for.

A simply encrypts some information using A's private key and B's public key... thereby ensuring:

* Only B can decrypt the information
* B can verify the information was
  encrypted by A (using A's public key)

There's no way for A to prove to B that their copy of the information has been destroyed or forgotten by A, but at least secure transmission is ensured.

> **Comments:**
> **username_0**: I totally agree that's the purpose of asymmetric encryption, my question was more about the practical way of doing it using existing blockchain mechanism, in ethereum or others. Can a contract do this?  
> **username_3**: There is nothing practical about forcing the entire world to see and store your data, as opposed to just giving it to who needs it.  

---

### Answer by username_4 on 2018-12-17. Score: 1

(Even though i'm on the bitcoin.stackexchange side this came up with an Ethereum tag so i'll answer from the Ethereum perspective)

Short answer is: Yes it is entirely possible. Using asymetric public key encryption as username_2 mentioned. It is however also entirely non-economical.

Some new, different, private/public chains have been specifically designed to handle data storage on-chain because current chains like Ethereum, make it cost prohibitive. As the amount of data you seek to store increases, the amount of effort to "mine" the transaction (with the data you want to store) also increases. That is why network fee's are calculate at a Byte rate.

Check out Tjaden's answer here: <https://ethereum.stackexchange.com/questions/872/what-is-the-cost-to-store-1kb-10kb-100kb-worth-of-data-into-the-ethereum-block>

My best attempt at answering the "smart contract to simplify" aspect would be

1. Already knowing the decryption key

or

2. Being able to decrypt data in a smart contract to get the decryption key.

In '2' you'd have a smart contract that would accept transactions with a set decryption. Every time A wanted to send a message that B could read, it would submit an encrypted, decryption key. B would have to find the transaction, decrypt the key, then use that key to decrypt the message. It's more like 2-auth but for an encrypted payload.

This would not be elegant or efficient. There are better ways to accomplish the same task.


---

### Answer by username_5 on 2017-07-28. Score: 0

I don't really understand what you are trying to do:

* If you want to prove that party A (and later party B) owns something, you can use a similar design as Bitcoin. Where bitcoins are send around by transactions where the "current holder" signs a message saying the bitcoins now belong to "a new holder".
* If you have a special smart contract which only the "current owner" is allowed to use and you want to pass ownership around more flexible. You can create another smart contract that holds "the current owner" in a more flexible way. See identity contracts in uPort.
* If party A wants to give some data party B (but no one else), why would you use a blockchain at all?

Could you more clearly specify what you mean with:

> and want to give the ownership of this data to B

In the blockchain world you just store this in the "ledger" (or blockchain), exactly the same as what bitcoin does.


---

