Following my previous question on this topic 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.


  • 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?

  • I’ve been thinking about this too. Have you found some kind of mechanism to at least partially do this?
    – el-flor
    Commented Nov 22, 2017 at 12:42

3 Answers 3


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.

  • 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
    Commented Jan 26, 2018 at 8:25
  • 1
    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. Commented Feb 24, 2018 at 18:25

(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 James 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


  1. 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.


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.