replace bip39 with @scure/bip39

This commit is contained in:
myxmaster
2026-06-02 21:56:52 +02:00
parent 423b3d794f
commit bc8e9da080
5 changed files with 17 additions and 19 deletions
-1
View File
@@ -78,7 +78,6 @@
"bech32": "2.0.0",
"bignumber.js": "9.0.2",
"bip32": "3.0.1",
"bip39": "3.1.0",
"bitcoinjs-lib": "6.1.5",
"bolt07": "1.9.4",
"bs58check": "2.1.2",
+8 -3
View File
@@ -11,8 +11,7 @@ import { bytesToHex } from '@noble/hashes/utils';
import hashjs from 'hash.js';
// @ts-ignore:next-line
import { getPublicKey, relayInit } from 'nostr-tools';
const bip39 = require('bip39');
import { mnemonicToEntropy, generateMnemonic } from '@scure/bip39';
import { sha256 } from 'js-sha256';
@@ -22,6 +21,7 @@ import SettingsStore from './SettingsStore';
import BackendUtils from '../utils/BackendUtils';
import Base64Utils from '../utils/Base64Utils';
import { BIP39_WORD_LIST } from '../utils/Bip39Utils';
import { sleep } from '../utils/SleepUtils';
import { localeString } from '../utils/LocaleUtils';
@@ -206,7 +206,12 @@ export default class LightningAddressStore {
const preimages = [];
for (let i = 0; i < 250; i++) {
preimages.push(
bip39.mnemonicToEntropy(bip39.generateMnemonic(256))
Buffer.from(
mnemonicToEntropy(
generateMnemonic(BIP39_WORD_LIST, 256),
BIP39_WORD_LIST
)
).toString('hex')
);
}
+7 -5
View File
@@ -4,9 +4,11 @@ import { ECPairAPI, ECPairFactory } from 'ecpair';
import ecc from '@bitcoinerlab/secp256k1';
import { crypto, initEccLib } from 'bitcoinjs-lib';
import { HDKey } from '@scure/bip32';
import { validateMnemonic } from '@scure/bip39';
const bip39 = require('bip39');
import {
validateMnemonic,
mnemonicToSeedSync,
generateMnemonic
} from '@scure/bip39';
import { themeColor } from '../utils/ThemeUtils';
import { localeString } from '../utils/LocaleUtils';
@@ -724,7 +726,7 @@ export default class SwapStore {
@action
public mnemonicToHDKey = (mnemonic: string) => {
const seed = bip39.mnemonicToSeedSync(mnemonic);
const seed = mnemonicToSeedSync(mnemonic);
const hdKey = HDKey.fromMasterSeed(seed);
return hdKey;
};
@@ -781,7 +783,7 @@ export default class SwapStore {
const mnemonic =
implementation === 'ldk-node' && ldkMnemonic
? ldkMnemonic
: bip39.generateMnemonic();
: generateMnemonic(BIP39_WORD_LIST);
await Storage.setItem(SWAPS_RESCUE_KEY, mnemonic);
return mnemonic;
+2 -3
View File
@@ -12,13 +12,12 @@
import * as necc from '@noble/secp256k1';
import { HDKey } from '@scure/bip32';
import createHash from 'create-hash';
import { mnemonicToSeedSync } from '@scure/bip39';
// Import noble_ecc to ensure hmacSha256Sync / sha256Sync are configured
// (required by necc.signSync)
import '../zeus_modules/noble_ecc';
const bip39 = require('bip39');
// 64-byte salt from vss-server SignatureValidatingAuthorizer
const SIGNING_CONSTANT = Buffer.from(
'VSS Signature Authorizer Signing Salt Constant..................',
@@ -37,7 +36,7 @@ export function deriveVssSigningKey(
mnemonic: string,
passphrase?: string
): { privateKey: Uint8Array; publicKey: Uint8Array } {
const seed = bip39.mnemonicToSeedSync(mnemonic, passphrase || '');
const seed = Buffer.from(mnemonicToSeedSync(mnemonic, passphrase || ''));
return deriveVssSigningKeyFromSeed(seed);
}
-7
View File
@@ -4583,13 +4583,6 @@ bip32@3.0.1:
typeforce "^1.11.5"
wif "^2.0.6"
bip39@3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/bip39/-/bip39-3.1.0.tgz#c55a418deaf48826a6ceb34ac55b3ee1577e18a3"
integrity sha512-c9kiwdk45Do5GL0vJMe7tS95VjCii65mYAH7DfWl3uW8AVzXKQVUm64i3hzVybBDMp9r7j9iNxR85+ul8MdN/A==
dependencies:
"@noble/hashes" "^1.2.0"
bitcoinjs-lib@6.1.5:
version "6.1.5"
resolved "https://registry.yarnpkg.com/bitcoinjs-lib/-/bitcoinjs-lib-6.1.5.tgz#3b03509ae7ddd80a440f10fc38c4a97f0a028d8c"