Skip to content

Commit

Permalink
swap out buffers for uint8arrays in mnemonicToSeedSync
Browse files Browse the repository at this point in the history
  • Loading branch information
adonesky1 committed Sep 6, 2022
1 parent 881c5e2 commit f8bd3f5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@ export function mnemonicToSeedSync(
wordlist: string[],
passphrase = ''
) {
let mnemonicBuffer;
let mnemonicUint8Array;
if (typeof mnemonic === 'string') {
mnemonicBuffer = Buffer.from(normalize(mnemonic).nfkd, 'utf8');
mnemonicUint8Array = new TextEncoder().encode(normalize(mnemonic).nfkd)
} else {
mnemonicBuffer = Buffer.from(
mnemonicUint8Array = new TextEncoder().encode(
Array.from(new Uint16Array(mnemonic.buffer))
.map((i) => wordlist[i])
.join(' ')
);
}
return pbkdf2(sha512, mnemonicBuffer, salt(passphrase), { c: 2048, dkLen: 64 });
return pbkdf2(sha512, mnemonicUint8Array, salt(passphrase), { c: 2048, dkLen: 64 });
}

0 comments on commit f8bd3f5

Please sign in to comment.