1

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.

  1. Is it possible to use a public key to encrypt the data and then store this on chain with PolkadotJS?
  2. 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?

1
  • Good question. Similarly, I've been wondering for a while if it's possible to store confidential data somehow accessible to the OCW in order to access protected API endpoints. In your case that confidential data would be a private key. On github there is a related issue but it hasn't been resolved, unfortunately.
    – Ronin
    Commented Jun 27 at 23:12

0

Browse other questions tagged or ask your own question.