//! 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
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
//! 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'
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))
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 })
}
//! 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'
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 })
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 {