Multi Key Encryption in web3-js

static_variablestatic_variable Member Posts: 11
Interested in writing a contract that will encrypt a json array with multiple public ethereum address keys, such that any one of the ethereum address holders can decrypt with their individual private key. Suggestions for references?


  • KenKKenK Member Posts: 44 admin
    edited July 2015
    Ethereum Addresses are not the public keys, rather they are a hash of the public key which is then shortened. Can I ask why you want to do this?
  • static_variablestatic_variable Member Posts: 11
    @KenK Yes, I meant to say public keys, not ethereum addresses. This question has to do with a dapp for encrypted medical messaging, intended for secure transmission to a limited number of selected recipients simultaneously. I came up with a strategy where a symmetric key would be used first, and then the key itself would be asymmetrically encrypted once for each intended recipient with their public key, and stored in the blockchain. However, I suspect that this type of functionality has already been worked out elsewhere in the ethereum ecosystem, either through native n-of-m multisig, or within Whisper.
  • gustav_simonssongustav_simonsson Member, Moderator Posts: 21 mod
    Encrypting in the actual contract code would be quite expensive, and also expose the plaintext key publicly :D

    On the other hand storing encrypted keys is easy, you can just put them in the account storage.
  • static_variablestatic_variable Member Posts: 11
    @gustav_simonsson Thanks! Can you clarify which web3 commands would encrypt the keys and place them in account storage?
  • static_variablestatic_variable Member Posts: 11
    @gustav_simonsson Rephrasing the question, if you are referring to
    web3.db.putString('testDB', 'key', 'myString')
    how can other nodes access the data stored on my node?
  • kevinkevin Member Posts: 5
    later on with super fast computers wouldn't it be possible to break that encryption and reveal the content of the data encrypted in the blockchain?

    I have a similar problem to solve and i'm wondering the best workaround to store the actual information ( and not only the prof of transactions ) on the blockchain.
Sign In or Register to comment.