I am trying to make a contract that receives an encrypted signed transaction and stores it for later use. This transaction can only be decrypted if the specified wallet sends a transaction to this contract telling it to forward this signed transaction to its destination.
1 Answer
In short, no.
A smart contract cannot safely hold a private key. Since every contract's code and storage is publically viewable, an attacker can simply read the key.
Any decryption must happen off-chain.
-
I get that but what if one user sends an encrypted signed transaction to the contract and the second user sends the decryption code and the contract matches the two, just like myetherwallet with the JSON files. The contract does not need to know the decryption code.– MbandoAug 29, 2017 at 4:25
-
Yes, that's possible, although it might be gas expensive. There may also be simpler ways of doing that. Aug 29, 2017 at 16:02
-
-
It would be much easier to simply have the contract record the encrypted transaction, and have the second user read it off the blockchain, decrypt it himself, and then broadcast it himself. You'll save a ton of gas. (Note: contracts cannot send signed transactions as if they came from the signing account, anyway.) Aug 29, 2017 at 22:16
-
So a contract wouldnt be able to trade on etherdelta by forwarding transactions from a wallet to the etherdelta contract?– MbandoAug 29, 2017 at 23:34