diff --git a/export/index.html b/export/index.html index 296a777..7ed5f12 100644 --- a/export/index.html +++ b/export/index.html @@ -96,9 +96,6 @@

Inject Key Export Bundle

-
- -

Inject Wallet Export Bundle

@@ -452,6 +449,9 @@

Message log

// TODO: this should be bundled at build time or replaced with code written by Turnkey entirely. import * as hpke from "https://esm.sh/@hpke/core"; import * as ed from "https://esm.sh/@noble/ed25519"; + import { sha512 } from 'https://esm.sh/@noble/hashes/sha512'; + + ed.etc.sha512Sync = (...m) => sha512(ed.etc.concatBytes(...m)); document.addEventListener("DOMContentLoaded", async () => { await TKHQ.initEmbeddedKey(); @@ -465,9 +465,9 @@

Message log

// We do not want to arbitrarily receive messages from all origins. window.addEventListener("message", async function(event) { if (event.data && event.data["type"] == "INJECT_KEY_EXPORT_BUNDLE") { - TKHQ.logMessage(`⬇️ Received message ${event.data["type"]}: ${event.data["value"]}, ${event.data["keyFormat"]}, ${event.data["publicKey"]}`); + TKHQ.logMessage(`⬇️ Received message ${event.data["type"]}: ${event.data["value"]}, ${event.data["keyFormat"]}`); try { - await onInjectKeyBundle(event.data["value"], event.data["keyFormat"], event.data["publicKey"]) + await onInjectKeyBundle(event.data["value"], event.data["keyFormat"]) } catch (e) { TKHQ.sendMessageUp("ERROR", e.toString()); } @@ -501,7 +501,6 @@

Message log

"type": "INJECT_KEY_EXPORT_BUNDLE", "value": document.getElementById("key-export-bundle").value, "keyFormat": document.getElementById("key-export-format").value, - "publicKey": document.getElementById("key-export-public-key").value, }) }, false); document.getElementById("inject-wallet").addEventListener("click", async e => { @@ -568,10 +567,6 @@

Message log

}); } - const getEd25519PublicKey = async (privateKeyHex) => { - return await ed.getPublicKey(privateKeyHex); - }; - /** * Function triggered when INJECT_KEY_EXPORT_BUNDLE event is received. * @param {string} bundle @@ -581,13 +576,14 @@

Message log

const keyBytes = await decryptBundle(bundle); // Parse the decrypted key bytes + var key; const privateKeyBytes = new Uint8Array(keyBytes); if (keyFormat === "SOLANA") { const privateKeyHex = TKHQ.uint8arrayToHexString(privateKeyBytes.subarray(0,32)); - const publicKeyBytes = getEd25519PublicKey(privateKeyHex); - const key = await TKHQ.encodeKey(privateKeyBytes, keyFormat, publicKeyBytes); + const publicKeyBytes = ed.getPublicKey(privateKeyHex); + key = await TKHQ.encodeKey(privateKeyBytes, keyFormat, publicKeyBytes); } else { - const key = await TKHQ.encodeKey(privateKeyBytes, keyFormat); + key = await TKHQ.encodeKey(privateKeyBytes, keyFormat); } // Display only the key