I'm generating the Public and Private key by using the Native Browser crypto API as below:
export const generateKeyPair = async (): Promise<CryptoKeyPair> => {
return await window.crypto.subtle.generateKey(
{
name: "ECDH",
namedCurve: "P-384",
},
true,
["deriveKey", "deriveBits"],
);
};
Then I'll export the publicKey
by using the exportKey
function under the window.crypto.subtle
as below:
const keyPair: CryptoKeyPair = yield generateKeyPair();
const publicKeyArrayBuffer: ArrayBuffer = yield window.crypto.subtle.exportKey("raw", keyPair.publicKey);
const publicKeyAsBase64 = arrayBufferToBase64(publicKeyArrayBuffer);
If you have any suggestions, please let me know and help me to fix this issue.