]> git.codecow.com Git - libnemo.git/commitdiff
Prune additional async methods from nano25519.
authorChris Duncan <chris@zoso.dev>
Fri, 3 Apr 2026 21:58:17 +0000 (14:58 -0700)
committerChris Duncan <chris@zoso.dev>
Fri, 3 Apr 2026 21:58:17 +0000 (14:58 -0700)
src/lib/account/index.ts
src/lib/block.ts
src/lib/tools.ts

index 183c2d74332ceb1afaab5f5142794d48d224673e..425458e64d40fa96c89843c28b923bf5f3e39dfa 100644 (file)
@@ -1,7 +1,7 @@
 //! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>\r
 //! SPDX-License-Identifier: GPL-3.0-or-later\r
 \r
-import * as nano25519 from 'nano25519'\r
+import { derive as nano25519_derive } from 'nano25519'\r
 import { Block } from '../block'\r
 import { ACCOUNT_KEY_BYTE_LENGTH, ACCOUNT_KEY_HEX_LENGTH } from '../constants'\r
 import { bytes, hex } from '../convert'\r
@@ -302,7 +302,7 @@ export class Account {
                                if (privateKey.byteLength !== ACCOUNT_KEY_BYTE_LENGTH) {\r
                                        throw new TypeError(`Private key must be ${ACCOUNT_KEY_BYTE_LENGTH} bytes`)\r
                                }\r
-                               const publicKey = nano25519.derive(privateKey)\r
+                               const publicKey = nano25519_derive(privateKey)\r
                                const address = new Address(publicKey)\r
                                this.#isInternal = true\r
                                const account = new this(address, publicKey, index)\r
index fa0f35009fd2861fe855bfd5e6f7144ca7b8a90a..17f5bc362d88ca6abfbc410be80863a922575cbb 100644 (file)
@@ -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 })
                }
index c1a7b2c320774f7e5636538502e080f8a7bb9f1f..ce548e5e3438a12ca2eb155fa8932e5b2e8a6cb5 100644 (file)
@@ -1,7 +1,7 @@
 //! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
 //! 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<ArrayBuffer>, ...input: string[]): Promise<string> {
                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<ArrayBuffer>, signature: string, ...input: string[]): Promise<boolean> {
                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 {