From 887f120cbdb5bcf2d1f84c1d14fedefa77c8a1cf Mon Sep 17 00:00:00 2001 From: minibits-cash Date: Tue, 10 Dec 2024 23:36:18 +0100 Subject: [PATCH] Upgrade of cashu-ts library to v2.0, improved handling of ecash states. --- ...2+1.5.0.patch => @scure+bip32+1.6.0.patch} | 28 ++++++++----------- ...9+1.4.0.patch => @scure+bip39+1.5.0.patch} | 6 ++-- 2 files changed, 15 insertions(+), 19 deletions(-) rename patches/{@scure+bip32+1.5.0.patch => @scure+bip32+1.6.0.patch} (71%) rename patches/{@scure+bip39+1.4.0.patch => @scure+bip39+1.5.0.patch} (90%) diff --git a/patches/@scure+bip32+1.5.0.patch b/patches/@scure+bip32+1.6.0.patch similarity index 71% rename from patches/@scure+bip32+1.5.0.patch rename to patches/@scure+bip32+1.6.0.patch index b6f7165..4d1cd1e 100644 --- a/patches/@scure+bip32+1.5.0.patch +++ b/patches/@scure+bip32+1.6.0.patch @@ -1,5 +1,5 @@ diff --git a/node_modules/@scure/bip32/index.ts b/node_modules/@scure/bip32/index.ts -index 51a702f..a13bf43 100644 +index 3368385..0659773 100644 --- a/node_modules/@scure/bip32/index.ts +++ b/node_modules/@scure/bip32/index.ts @@ -8,6 +8,7 @@ import { bytesToHex, concatBytes, createView, hexToBytes, utf8ToBytes } from '@n @@ -10,32 +10,28 @@ index 51a702f..a13bf43 100644 const Point = secp.ProjectivePoint; const base58check = createBase58check(sha256); -@@ -93,7 +94,9 @@ export class HDKey { - `HDKey: wrong seed length=${seed.length}. Should be between 128 and 512 bits; 256 bits is advised)` +@@ -97,7 +98,8 @@ export class HDKey { + seed.length ); } - const I = hmac(sha512, MASTER_SECRET, seed); -+ // const I = hmac(sha512, MASTER_SECRET, seed); -+ // console.log('[fromMasterSeed] Using patched hmac'); -+ const I = new Uint8Array(QuickCrypto.createHmac('sha512', MASTER_SECRET).update(seed).digest()); ++ //const I = hmac(sha512, MASTER_SECRET, seed); ++ const I = new Uint8Array(QuickCrypto.createHmac('sha512', MASTER_SECRET).update(seed).digest()); return new HDKey({ versions, chainCode: I.slice(32), -@@ -217,7 +220,11 @@ export class HDKey { +@@ -220,7 +222,8 @@ export class HDKey { // Normal child: serP(point(kpar)) || ser32(index) data = concatBytes(this.pubKey, data); } - const I = hmac(sha512, this.chainCode, data); -+ -+ // const I = hmac(sha512, this.chainCode, data); -+ // console.log('[deriveChild] Using patched hmac'); -+ const I = new Uint8Array(QuickCrypto.createHmac('sha512', this.chainCode).update(data).digest()); -+ ++ // const I = hmac(sha512, this.chainCode, data); ++ const I = new Uint8Array(QuickCrypto.createHmac('sha512', this.chainCode).update(data).digest()); const childTweak = bytesToNumber(I.slice(0, 32)); const chainCode = I.slice(32); if (!secp.utils.isValidPrivateKey(childTweak)) { diff --git a/node_modules/@scure/bip32/package.json b/node_modules/@scure/bip32/package.json -index 15a1215..1aea96c 100644 +index 5222d18..69ff82b 100644 --- a/node_modules/@scure/bip32/package.json +++ b/node_modules/@scure/bip32/package.json @@ -6,15 +6,8 @@ @@ -44,7 +40,7 @@ index 15a1215..1aea96c 100644 ], - "main": "./lib/index.js", - "module": "./lib/esm/index.js", -+ "main": "./index.ts", ++ "main": "./index.ts", "types": "./lib/index.d.ts", - "exports": { - ".": { @@ -53,5 +49,5 @@ index 15a1215..1aea96c 100644 - } - }, "dependencies": { - "@noble/curves": "~1.6.0", - "@noble/hashes": "~1.5.0", + "@noble/curves": "~1.7.0", + "@noble/hashes": "~1.6.0", diff --git a/patches/@scure+bip39+1.4.0.patch b/patches/@scure+bip39+1.5.0.patch similarity index 90% rename from patches/@scure+bip39+1.4.0.patch rename to patches/@scure+bip39+1.5.0.patch index 29e9fc1..6a715e8 100644 --- a/patches/@scure+bip39+1.4.0.patch +++ b/patches/@scure+bip39+1.5.0.patch @@ -1,5 +1,5 @@ diff --git a/node_modules/@scure/bip39/package.json b/node_modules/@scure/bip39/package.json -index a903f6e..0bc8651 100644 +index c30d78b..95af581 100644 --- a/node_modules/@scure/bip39/package.json +++ b/node_modules/@scure/bip39/package.json @@ -45,7 +45,7 @@ @@ -12,7 +12,7 @@ index a903f6e..0bc8651 100644 "exports": { ".": { diff --git a/node_modules/@scure/bip39/src/index.ts b/node_modules/@scure/bip39/src/index.ts -index e6afe12..c4546b4 100644 +index 5cd4255..6fba64b 100644 --- a/node_modules/@scure/bip39/src/index.ts +++ b/node_modules/@scure/bip39/src/index.ts @@ -5,6 +5,7 @@ import { sha256 } from '@noble/hashes/sha256'; @@ -30,6 +30,6 @@ index e6afe12..c4546b4 100644 - return pbkdf2(sha512, normalize(mnemonic).nfkd, salt(passphrase), { c: 2048, dkLen: 64 }); + // const original = pbkdf2(sha512, normalize(mnemonic).nfkd, salt(passphrase), { c: 2048, dkLen: 64 }); + const updated = new Uint8Array(QuickCrypto.pbkdf2Sync(normalize(mnemonic).nfkd, salt(passphrase), 2048, 64, 'sha512')); -+ console.log('[@scure.bip39.mnemonicToSeedSync] Patched to use QuickCrypto.pbkdf2Sync') ++ // console.log('[@scure.bip39.mnemonicToSeedSync] Patched to use QuickCrypto.pbkdf2Sync') + return updated }