I want to create a StorageMap which looks like so:
pub type EncryptedData<T: Config> = StorageMap<_, Blake2_128Concat, SomeId, SomeEncryptedValue, OptionQuery>;
I plan to encrypt the data offchain and then store this data on chain by submitting extrinsics.
I will also create an offchain worker which will need to be able to decrypt the data stored in the StorageMap. My plan is to store a private key in the node keystore and allow the offchain worker to utilise this key for submitting extrinsics to modify the chain state.
- Is it possible to use a public key to encrypt the data and then store this on chain with PolkadotJS?
- Is it possible to allow the offchain worker to use corresponding private key to decrypt the data?
My offchain worker needs to recover the actual value that was encrypted and use it for some computation.
Can anyone give me an overview of how to do this? I can't see anything obvious in the sp_*
libraries that would allow me to decrypt and recover the raw data, so do I need to use an external crate?