From: Chris Duncan Date: Mon, 4 Aug 2025 13:57:32 +0000 (-0700) Subject: Type check entropy and checksum concatenation. Ensure mnemonic phrase is lowercase... X-Git-Tag: v0.10.5~46^2~18 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=c96a2e4089ea5084901febbe86b185f5d4fe9ac4;p=libnemo.git Type check entropy and checksum concatenation. Ensure mnemonic phrase is lowercase when imported. --- diff --git a/src/lib/bip39-mnemonic.ts b/src/lib/bip39-mnemonic.ts index 1305a39..d3fc409 100644 --- a/src/lib/bip39-mnemonic.ts +++ b/src/lib/bip39-mnemonic.ts @@ -48,7 +48,7 @@ export class Bip39Mnemonic { e = e << 8n | BigInt(entropy[i]) } - let concatenation = (e << BigInt(entropy.byteLength) / 4n) | checksum + let concatenation: bigint = (e << BigInt(entropy.byteLength) / 4n) | checksum const words: string[] = [] for (let i = 0; i < phraseLength; i++) { const wordBits = concatenation & 2047n @@ -74,7 +74,7 @@ export class Bip39Mnemonic { const self = new this() const isValid = await this.validate(phrase) if (isValid) { - self.#phrase = phrase.normalize('NFKD').split(' ') + self.#phrase = phrase.normalize('NFKD').toLowerCase().split(' ') return self } else { throw new Error('Invalid mnemonic phrase.')