Optimize bip39 list for size (#1190)

This commit is contained in:
Jaco
2021-11-15 16:32:48 +02:00
committed by GitHub
parent 19283b3c28
commit a953b3a78a
2 changed files with 2057 additions and 10 deletions
File diff suppressed because one or more lines are too long
+9 -9
View File
@@ -38,18 +38,18 @@ function bytesToBinary (bytes: number[]): string {
}
function deriveChecksumBits (entropyBuffer: Uint8Array): string {
const ENT = entropyBuffer.length * 8;
const CS = ENT / 32;
const result = hash.sha256().update(entropyBuffer).digest();
return bytesToBinary(Array.from(result)).slice(0, CS);
return bytesToBinary(
Array.from(
hash.sha256().update(entropyBuffer).digest()
)
).slice(0, (entropyBuffer.length * 8) / 32);
}
export function mnemonicToSeedSync (mnemonic: string, password?: string): Uint8Array {
const mnemonicBuffer = stringToU8a(normalize(mnemonic));
const saltBuffer = stringToU8a(`mnemonic${normalize(password)}`);
return pbkdf2Encode(mnemonicBuffer, saltBuffer).password;
return pbkdf2Encode(
stringToU8a(normalize(mnemonic)),
stringToU8a(`mnemonic${normalize(password)}`)
).password;
}
export function mnemonicToEntropy (mnemonic: string): Uint8Array {