2

Is there a way of encrypting substrate storage using the root key pair? Or is there anyway of making on chain data private to everyone but the system.

thanks

1 Answer 1

2

All the information on a blockchain is public and available to all the participants of the network.

You can encrypt the data you want to store offchain using your keypair and store it the storage, see an example of how to Encrypt & Decrypt Messages with the PolkadotJS library.

See I highlighted the offchain word. It is important you do not encrypt it using a smart contract or a extrinsic, because the input of the extrinsic will have the raw data and it will be public and visible to all. In other words encrypt data before it is added to a blockchain, and then decrypt it after it has been retrieved from the blockchain.

With that said, think twice if you want to store sensible data in the Blockchain. One of the properties of Blockchain is immutability, that means that even if stored in encrypted form, the critical data will remain in the blockchain forever. In addition to the risk of key compromise, the encrypted data may be subject to brute force decryption attacks in the future, or breakthroughs in technology like quantum computing might render current encryption technologies ineffective.

4
  • Even if the user wants to encrypt data on chain using an extrinsic, isn't encryption a taxing process for a 2 second transaction process time ?
    – b0zero
    Commented Jan 31, 2023 at 6:28
  • If you do it on-chain through and extrinsic everyone will be able to see the input of the extrinsic (the data you want to encrypt)
    – Alex Bean
    Commented Jan 31, 2023 at 8:33
  • 1
    Yes, but I am asking if encryption is a heavy process (in terms of weight consumed)
    – b0zero
    Commented Jan 31, 2023 at 9:32
  • This is true too, will consume more resources to do it onchain
    – Alex Bean
    Commented Jan 31, 2023 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.