Files
minibits_wallet/patches/@scure+bip39+1.6.0.patch
T
2026-01-10 00:39:30 +01:00

45 lines
2.6 KiB
Diff

diff --git a/node_modules/@scure/bip39/esm/index.js b/node_modules/@scure/bip39/esm/index.js
index d5734b0..deb1491 100644
--- a/node_modules/@scure/bip39/esm/index.js
+++ b/node_modules/@scure/bip39/esm/index.js
@@ -32,6 +32,7 @@ import { pbkdf2, pbkdf2Async } from '@noble/hashes/pbkdf2';
import { sha256, sha512 } from '@noble/hashes/sha2';
import { abytes, anumber, randomBytes } from '@noble/hashes/utils';
import { utils as baseUtils } from '@scure/base';
+import quickCrypto from 'react-native-quick-crypto'
// Japanese wordlist
const isJapanese = (wordlist) => wordlist[0] === '\u3042\u3044\u3053\u304f\u3057\u3093';
// Normalization replaces equivalent sequences of characters
@@ -157,5 +158,7 @@ export function mnemonicToSeed(mnemonic, passphrase = '') {
* // new Uint8Array([...64 bytes])
*/
export function mnemonicToSeedSync(mnemonic, passphrase = '') {
- return pbkdf2(sha512, normalize(mnemonic).nfkd, psalt(passphrase), { c: 2048, dkLen: 64 });
+ console.log('[bip39.mnemonicToSeedSync] Using ESM quickCrypto PBKDF2 Sync');
+ return new Uint8Array(quickCrypto.pbkdf2Sync(normalize(mnemonic).nfkd, psalt(passphrase), 2048, 64, 'sha512'));
+ //return pbkdf2(sha512, normalize(mnemonic).nfkd, psalt(passphrase), { c: 2048, dkLen: 64 });
}
diff --git a/node_modules/@scure/bip39/src/index.ts b/node_modules/@scure/bip39/src/index.ts
index 4284c3e..71e39e9 100644
--- a/node_modules/@scure/bip39/src/index.ts
+++ b/node_modules/@scure/bip39/src/index.ts
@@ -33,6 +33,7 @@ import { pbkdf2, pbkdf2Async } from '@noble/hashes/pbkdf2';
import { sha256, sha512 } from '@noble/hashes/sha2';
import { abytes, anumber, randomBytes } from '@noble/hashes/utils';
import { utils as baseUtils } from '@scure/base';
+import QuickCrypto from 'react-native-quick-crypto'
// Japanese wordlist
const isJapanese = (wordlist: string[]) => wordlist[0] === '\u3042\u3044\u3053\u304f\u3057\u3093';
@@ -170,5 +171,9 @@ export function mnemonicToSeed(mnemonic: string, passphrase = ''): Promise<Uint8
* // new Uint8Array([...64 bytes])
*/
export function mnemonicToSeedSync(mnemonic: string, passphrase = ''): Uint8Array {
- return pbkdf2(sha512, normalize(mnemonic).nfkd, psalt(passphrase), { c: 2048, dkLen: 64 });
+ // return pbkdf2(sha512, normalize(mnemonic).nfkd, psalt(passphrase), { c: 2048, dkLen: 64 });
+ console.log('[mnemonicToSeedSync] Using TS quickCrypto PBKDF2 Sync');
+ const updated = new Uint8Array(QuickCrypto.pbkdf2Sync(normalize(mnemonic).nfkd, psalt(passphrase), 2048, 64, 'sha512'));
+ // console.log('[@scure.bip39.mnemonicToSeedSync] Patched to use QuickCrypto.pbkdf2Sync')
+ return updated
}