3

My use case is the following: I want to use ethereum to track devices, and device owners. This is easy to do using ethereum and smart contract. But I want to store a secret associated with the device. Is there a way to do this, for instance, by encrypting this secret data with the public key of the holder?

Basically, if A=Asset, O1= A first owner, O2=A next owner, I would like to achieve this:

  1. A is owned by O1, A secret is encrypted with O1 public key, and stored in the blockchain
  2. A is transferred by O1 to O2 (new owner) using a smart contract executed by O1. O1 decrpyt A secret using his private key, and encrypt it using O2 public key and store this
  3. A is owned by O2, A secret is encrypted with O2 public key and stored in the blockchain

This seems fine except that the smart contract needs to access to some secret key... Is there an idea how such contract can be done, or if there is a better option for this ?

  • What's the purpose of the secret? Who defines the secret for a specific device? Is it the secret the same for one device when it changes owner? – bordalix May 15 '18 at 14:05
  • @bordalix : the secret is defined somewhere else (by the dev creator for instance), and don't change when the device change of owner. The flaw is that the previous owner still have the secret, but that's not adressed by this and it's a know issue.... – tomsoft May 16 '18 at 15:28
  • who will put the device firstly on the blockchain? the dev creator? if so, why can't he put the secret there encrypted with his public key? do owners need to know the secret? – bordalix May 16 '18 at 15:41
5

You can't do it into the smartcontract, because of the blockchain pseudo-random property doesn't guarantee you that the encrypted info is totally unencryptable.

All of the info is public on the blockchain, that's why lots of apps have problems with GDPR or LOPD laws.

But another user did something to solve it, creating code on nodejs/browser envoirment . Here you have the link to the post.

Check also https://github.com/pubkey/eth-crypto which may be helpful to you ir order to resolve that problem.

Hope it helps!

  • What do you mean by "pseudo-random property"? I'm not aware of that term. I also think that something like what the Op asks for is in fact possible to do in a smart contract. You just have to avoid actual decryption on the blockchain, but I think that could be done with some RSA trickery. – mafrasi2 May 31 '18 at 23:09
  • The library is good, but it would be nice if there was a metamask feature to easily do this... Anyway, thanks for the feedback. – tomsoft May 24 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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