mirror of
https://github.com/minibits-cash/minibits_wallet.git
synced 2026-07-22 07:48:28 +00:00
Add quickCrypto patch for nested @scure/bip32 in cashu-ts
Patch cashu-ts's nested @scure/bip32@2.0.1 dependency to use react-native-quick-crypto for HMAC-SHA512 operations in BIP32 key derivation. This improves wallet recovery performance. - Add patches/@cashu+cashu-ts++@scure+bip32+2.0.1.patch - Enable scripts in .yarnrc.yml for patch-package Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,3 +3,5 @@ nodeLinker: node-modules
|
||||
yarnPath: .yarn/releases/yarn-3.6.4.cjs
|
||||
|
||||
checksumBehavior: update
|
||||
|
||||
enableScripts: true
|
||||
|
||||
34
patches/@cashu+cashu-ts++@scure+bip32+2.0.1.patch
Normal file
34
patches/@cashu+cashu-ts++@scure+bip32+2.0.1.patch
Normal file
@@ -0,0 +1,34 @@
|
||||
diff --git a/node_modules/@cashu/cashu-ts/node_modules/@scure/bip32/index.js b/node_modules/@cashu/cashu-ts/node_modules/@scure/bip32/index.js
|
||||
index 935277b..6a76a8c 100644
|
||||
--- a/node_modules/@cashu/cashu-ts/node_modules/@scure/bip32/index.js
|
||||
+++ b/node_modules/@cashu/cashu-ts/node_modules/@scure/bip32/index.js
|
||||
@@ -23,6 +23,7 @@ import { ripemd160 } from '@noble/hashes/legacy.js';
|
||||
import { sha256, sha512 } from '@noble/hashes/sha2.js';
|
||||
import { abytes, concatBytes, createView } from '@noble/hashes/utils.js';
|
||||
import { createBase58check } from '@scure/base';
|
||||
+import quickCrypto from 'react-native-quick-crypto';
|
||||
const Point = secp.Point;
|
||||
const { Fn } = Point;
|
||||
const base58check = createBase58check(sha256);
|
||||
@@ -87,7 +88,9 @@ export class HDKey {
|
||||
throw new Error('HDKey: seed length must be between 128 and 512 bits; 256 bits is advised, got ' +
|
||||
seed.length);
|
||||
}
|
||||
- const I = hmac(sha512, MASTER_SECRET, seed);
|
||||
+ // const I = hmac(sha512, MASTER_SECRET, seed);
|
||||
+ console.log('[bip32 v2.0.1 fromMasterSeed] Using quickCrypto HMAC');
|
||||
+ const I = new Uint8Array(quickCrypto.createHmac('sha512', MASTER_SECRET).update(seed).digest());
|
||||
const privateKey = I.slice(0, 32);
|
||||
const chainCode = I.slice(32);
|
||||
return new HDKey({ versions, chainCode, privateKey });
|
||||
@@ -206,7 +209,9 @@ export class HDKey {
|
||||
// Normal child: serP(point(kpar)) || ser32(index)
|
||||
data = concatBytes(this._publicKey, data);
|
||||
}
|
||||
- const I = hmac(sha512, this.chainCode, data);
|
||||
+ // const I = hmac(sha512, this.chainCode, data);
|
||||
+ console.log('[bip32 v2.0.1 deriveChild] Using quickCrypto HMAC');
|
||||
+ const I = new Uint8Array(quickCrypto.createHmac('sha512', this.chainCode).update(data).digest());
|
||||
const childTweak = I.slice(0, 32);
|
||||
const chainCode = I.slice(32);
|
||||
if (!secp.utils.isValidSecretKey(childTweak)) {
|
||||
@@ -16545,7 +16545,7 @@ __metadata:
|
||||
peerDependenciesMeta:
|
||||
"@expo/config-plugins":
|
||||
optional: true
|
||||
checksum: 4f38adfbd60124f96121a31eaadecd48cb72d50afcfff228be7bfba92ec1051154a2b8acd2cf8c8d0e0c6d12172f48237791d0ecb3a726f8915151ab652b79a5
|
||||
checksum: efd9e1eeee2b75a83d366687a9acf58b4f0a4f4a32b563783cacf1b9308bdccb81afdb065d7df469e5308e3163d5f6b5e2561ea5c8ea5e9abc1ded623b19d697
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
||||
Reference in New Issue
Block a user