I need to write down methods to encrypt
and decrypt
string messages using contract private
| public
keys in a smart contract. However you may think it’s dangerous or anything else, the question is: Is it possible to use a smart contract private key inside it’s methods to encrypt or decrypt data?
This is a short and simple example. I need to implement the encode/decode inside the methods.
contract Secret { function encode(string memory message) public returns (string) { // ...implementation } function decode(string memory message) public returns (string) { // ...implementation } }