From ed2d5c8be29a45fc643aece9ea4336be7cc51595 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Fri, 3 Apr 2026 14:58:17 -0700 Subject: [PATCH] Prune additional async methods from nano25519. --- src/lib/account/index.ts | 4 ++-- src/lib/block.ts | 8 ++++---- src/lib/tools.ts | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lib/account/index.ts b/src/lib/account/index.ts index 183c2d7..425458e 100644 --- a/src/lib/account/index.ts +++ b/src/lib/account/index.ts @@ -1,7 +1,7 @@ //! SPDX-FileCopyrightText: 2025 Chris Duncan //! SPDX-License-Identifier: GPL-3.0-or-later -import * as nano25519 from 'nano25519' +import { derive as nano25519_derive } from 'nano25519' import { Block } from '../block' import { ACCOUNT_KEY_BYTE_LENGTH, ACCOUNT_KEY_HEX_LENGTH } from '../constants' import { bytes, hex } from '../convert' @@ -302,7 +302,7 @@ export class Account { if (privateKey.byteLength !== ACCOUNT_KEY_BYTE_LENGTH) { throw new TypeError(`Private key must be ${ACCOUNT_KEY_BYTE_LENGTH} bytes`) } - const publicKey = nano25519.derive(privateKey) + const publicKey = nano25519_derive(privateKey) const address = new Address(publicKey) this.#isInternal = true const account = new this(address, publicKey, index) diff --git a/src/lib/block.ts b/src/lib/block.ts index fa0f350..17f5bc3 100644 --- a/src/lib/block.ts +++ b/src/lib/block.ts @@ -2,7 +2,7 @@ //! SPDX-License-Identifier: GPL-3.0-or-later import { NanoPow } from 'nano-pow' -import * as nano25519 from 'nano25519' +import { derive as nano25519_derive, sign as nano25519_sign, verify as nano25519_verify } from 'nano25519' import { Account } from './account' import { BURN_PUBLIC_KEY, DIFFICULTY_RECEIVE, DIFFICULTY_SEND, PREAMBLE, UNITS } from './constants' import { bytes, dec, hex } from './convert' @@ -413,8 +413,8 @@ export class Block { try { if (typeof input === 'string' && /^[A-F0-9]{64}$/i.test(input)) { const prv = hex.toBytes(input) - const pub = nano25519.derive(prv) - const signature = nano25519.sign(hex.toBytes(this.hash), new Uint8Array([...prv, ...pub])) + const pub = nano25519_derive(prv) + const signature = nano25519_sign(hex.toBytes(this.hash), new Uint8Array([...prv, ...pub])) this.signature = bytes.toHex(signature) } else if (input instanceof Wallet && typeof index === 'number' && (frontier === undefined || frontier instanceof (this.constructor as typeof Block)) @@ -446,7 +446,7 @@ export class Block { if (typeof key !== 'string') { throw new Error('Invalid key') } - return await nano25519.verify(hex.toBytes(this.signature ?? ''), hex.toBytes(this.hash), hex.toBytes(key)) + return await nano25519_verify(hex.toBytes(this.signature ?? ''), hex.toBytes(this.hash), hex.toBytes(key)) } catch (err) { throw new Error('Failed to verify block signature', { cause: err }) } diff --git a/src/lib/tools.ts b/src/lib/tools.ts index c1a7b2c..ce548e5 100644 --- a/src/lib/tools.ts +++ b/src/lib/tools.ts @@ -1,7 +1,7 @@ //! SPDX-FileCopyrightText: 2025 Chris Duncan //! SPDX-License-Identifier: GPL-3.0-or-later -import * as nano25519 from 'nano25519' +import { sign as nano25519_sign, verify as nano25519_verify } from 'nano25519' import { Account } from './account' import { Block } from './block' import { MAX_SUPPLY, UNITS } from './constants' @@ -141,7 +141,7 @@ export class Tools { static async sign (key: string | Uint8Array, ...input: string[]): Promise { if (typeof key === 'string') key = hex.toBytes(key) try { - const signature = nano25519.sign(this.hash(input), key) + const signature = nano25519_sign(this.hash(input), key) return bytes.toHex(signature) } catch (err) { throw new Error(`Failed to sign message with private key`, { cause: err }) @@ -219,7 +219,7 @@ export class Tools { static async verify (key: string | Uint8Array, signature: string, ...input: string[]): Promise { if (typeof key === 'string') key = hex.toBytes(key) try { - return nano25519.verify(hex.toBytes(signature), this.hash(input), key) + return nano25519_verify(hex.toBytes(signature), this.hash(input), key) } catch (err) { throw new Error('Failed to verify signature', { cause: err }) } finally { -- 2.47.3