diff --git a/src/services/crypto.service.ts b/src/services/crypto.service.ts index 6f5b201ab2f..01b4ba4b623 100644 --- a/src/services/crypto.service.ts +++ b/src/services/crypto.service.ts @@ -690,20 +690,18 @@ export class CryptoService implements CryptoServiceAbstraction { return okm; } - private async hashPhrase(data: ArrayBuffer, minimumEntropy: number = 64, hashIterations: number = 50000) { + private async hashPhrase(hash: ArrayBuffer, minimumEntropy: number = 64) { const entropyPerWord = Math.log(EEFLongWordList.length) / Math.log(2); let numWords = Math.ceil(minimumEntropy / entropyPerWord); - const hashBuffer = await this.cryptoFunctionService.pbkdf2(data, new Uint8Array([]).buffer, - 'sha256', hashIterations); - const hash = Array.from(new Uint8Array(hashBuffer)); - const entropyAvailable = hash.length * 4; + const hashArr = Array.from(new Uint8Array(hash)); + const entropyAvailable = hashArr.length * 4; if (numWords * entropyPerWord > entropyAvailable) { throw new Error('Output entropy of hash function is too small'); } const phrase: string[] = []; - let hashNumber = bigInt.fromArray(hash, 256); + let hashNumber = bigInt.fromArray(hashArr, 256); while (numWords--) { const remainder = hashNumber.mod(EEFLongWordList.length); hashNumber = hashNumber.divide(EEFLongWordList.length);