according to bip39 standard, I want to get seed from mnemonic words in javascript.
I use this code:
function mnemonicToSeed(mnemonic,passphrase){
if (typeof passphrase != 'string') passphrase='';
window.crypto.subtle.importKey(
'raw',
stringToArrayBuffer(mnemonic),
{
name: 'PBKDF2',
},
false,
['deriveKey']
).then((importedKey) => {
crypto.subtle.deriveKey({
name: "PBKDF2",
salt: stringToArrayBuffer('mnemonic'+passphrase),
iterations: 2048,
hash: { name: 'SHA-512' }
},
importedKey,
{
name: 'HMAC',
hash: 'SHA-512',
length: 512
},
true,
['sign']
).then(function(derivedKey) {
console.log('derivedKey: '+derivedKey);
});
});
}
but at last result of console.log('derivedKey: '+derivedKey);
is this:
derivedKey: [object CryptoKey]
now how convert derivedKey to its corresponding seed as hex string ?