From f6482c4f2daf24f791aa57f393485a32436516b3 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sat, 9 Aug 2025 00:24:35 -0700 Subject: [PATCH] Move an imported constant used in only one place. --- src/lib/constants.ts | 2 -- src/lib/crypto/bip39.ts | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 8fdc08a..48c67ca 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -5,7 +5,6 @@ export const ACCOUNT_KEY_BYTE_LENGTH = 32 export const ACCOUNT_KEY_HEX_LENGTH = 64 export const ADDRESS_GAP = 20 export const ALPHABET = '13456789abcdefghijkmnopqrstuwxyz' -export const BIP39_ITERATIONS = 2048 export const BIP44_PURPOSE = 44 export const BIP44_COIN_NANO = 165 export const BURN_ADDRESS = 'nano_1111111111111111111111111111111111111111111111111111hifc8npp' @@ -67,7 +66,6 @@ export default ` const ACCOUNT_KEY_HEX_LENGTH = ${ACCOUNT_KEY_HEX_LENGTH} const ADDRESS_GAP = ${ADDRESS_GAP} const ALPHABET = '${ALPHABET}' - const BIP39_ITERATIONS = ${BIP39_ITERATIONS} const BIP44_PURPOSE = ${BIP44_PURPOSE} const BIP44_COIN_NANO = ${BIP44_COIN_NANO} const BURN_ADDRESS = '${BURN_ADDRESS}' diff --git a/src/lib/crypto/bip39.ts b/src/lib/crypto/bip39.ts index bd94034..7baf54a 100644 --- a/src/lib/crypto/bip39.ts +++ b/src/lib/crypto/bip39.ts @@ -1,7 +1,6 @@ //! SPDX-FileCopyrightText: 2025 Chris Duncan //! SPDX-License-Identifier: GPL-3.0-or-later -import { BIP39_ITERATIONS } from '../constants' import { bytes, utf8 } from '../convert' /** @@ -9,6 +8,7 @@ import { bytes, utf8 } from '../convert' */ export class Bip39 { static #isInternal: boolean = false + static #ITERATIONS: 2048 = 2048 /** * SHA-256 hash of entropy that is appended to the entropy and subsequently @@ -203,7 +203,7 @@ export class Bip39 { name: 'PBKDF2', hash: 'SHA-512', salt: utf8.toBytes(`mnemonic${salt.normalize('NFKD')}`), - iterations: BIP39_ITERATIONS + iterations: Bip39.#ITERATIONS } const seed = await crypto.subtle.deriveBits(algorithm, phraseKey, 512) this.#bip39Seed = new Uint8Array(seed) -- 2.47.3