I thinking of developing some kind of application in which I need to have some kind of public key cryptography
done by the smart contract
. The sender
sends some data to the smart contract
encrypyted by smart contract
's public key
, will the smart contract
be able to decrypt it, using the smart contract
s private key
? While the smart contract
decrypts the data, will everyone be able to see the plain text since its replicated on all the nodes ?
Since the smart contract
is replicated on all the nodes across the network, will every one be able to see all the contents of the smart contract
?
Best Answer
Short answer: yes.
If the contract does the decryption, it needs to store the private key. If the private key is stored in the contract, it is replicated to every node, and yes, as a result every node will do the decryption.
There is probably some cryptographically complex way to do what you want, but I'd guess it's one of those things that you want reviewed by lots of people who know crypto and blockchains, and if you get even a bit of it wrong, your data would be vulnerable.
Depending on your use case, you might have data sent (encrypted with the contract's public key) to the contract and stored, but only decrypted by a node/app you control that has the private key secured.