This is a working example on how to store
CryptoKeys locally in your browser. We are able to save the objects, without serializing them. This means we can keep them not exportable (which might be more secure?? not sure what attack vectors this prevents).
To try out this example, first make sure you are in a browser that has support for
async...await and indexedDB (latest chrome canary with
encryptDataSaveKey(). This will create a private/public key pair and encrypted some random data with the private key. Then save both of them. Now reload the page, copy in the code, and run
loadKeyDecryptData(). It will load the keys and encrypted data and decrypt it. You should see the same data logged both times.