I'm trying to find a way to use an ethereum address/solidity/web3 for text encryption , but i'm not even sure it's possible to get the public key from the address(hash of the pubkey) using secp256k1 to get the publickey ? or if there is any other way to access it client side? if so, would the user be able to decrypt the data using it's passphrase(ethereum passphrase )? so that everything would happen client side but the data would be stored encrypted on the chain ?

I know none of this is really meant to do any of that but i'm trying to store encrypted data on the blockchain without having to rely on a server to store keys as much as possible but can't seems to find a way.


Ethereum + data = encrypted data

encrypted data + ethereum + passphrase = data

2 Answers 2


You can extract an address and public key from a signature - see ecrecover.

There are several approaches you could take to do what you want to accomplish. One would be to store public keys in a contract. When I want to send someone an encrypted message I grab their public key through a contract, encrypt the data and send it. They will be able to decrypt with the associated private key.

One thing to keep in mind, anything your store on the blockchain can be read by anyone.

  • but how would the user go about decrypting the data with just mist ? Would he need to extract his private key somehow ?
    – user697
    Commented Apr 29, 2016 at 7:36
  • For now all this would have to be done outside of Mist.
    – dbryson
    Commented Apr 29, 2016 at 12:08

It would be better to use IPFS or Filecoin to store longer items of text, then use Ethereum to store the access keys. IPFS is still distributed, but if you're concerned about privacy, just note that your IP address isn't private using this method. Ethereum disincentivizes using the network as a database for storing large gluts of data.

You can certainly use a smart contract to encrypt the block of text using the sha3 commands (look up documentation for syntax) and then create functions that add and read from IPFS.

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.