+/* TODO: duplicate in both client.js and host.jhs */
+function getPublicKey() {
+ /* Check local storage for public key */
+ if (window.localStorage.getItem('public-key') === undefined) {
+ /* If doesn't exist, generate public and private key pair, store in
+ local storage */
+ crypto.subtle.generateKey({name:'RSA-OAEP', length: 192}, true, ['encrypt', 'decrypt'])
+ .then((keyPair) => {
+ /* TODO: Do we need to store the private key as well? */
+ window.localStorage.setItem('public-key', keyPair.type.public.toString())
+ })
+ }
+ console.log(window.localStorage.getItem('public-key'))
+ return window.localStorage.getItem('public-key')
+}