From 3ddb1840b34770dd08cb9a1ff90297ee8010de16 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Tue, 3 Dec 2024 14:38:23 -0800 Subject: [PATCH] Return public key as hex string from NanoNaCl. --- src/lib/account.ts | 4 ++-- src/lib/nano-nacl.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/account.ts b/src/lib/account.ts index 3e4a987..f9d7d1d 100644 --- a/src/lib/account.ts +++ b/src/lib/account.ts @@ -109,8 +109,8 @@ export class Account { static fromPrivateKey (privateKey: string, index?: number): Account { Account.#isInternal = true Account.#validateKey(privateKey) - const { publicKey } = NanoNaCl.convert(privateKey) - const account = Account.fromPublicKey(bytes.toHex(publicKey), index) + const publicKey = NanoNaCl.convert(privateKey) + const account = Account.fromPublicKey(publicKey, index) account.#prv = privateKey.toUpperCase() return account } diff --git a/src/lib/nano-nacl.ts b/src/lib/nano-nacl.ts index 9ff8e24..5338b20 100644 --- a/src/lib/nano-nacl.ts +++ b/src/lib/nano-nacl.ts @@ -808,7 +808,7 @@ const n = () => { return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0) } - const convert = function (seed: string | Uint8Array) { + const convert = function (seed: string | Uint8Array): string { if (typeof seed === 'string') seed = parseHex(seed) checkArrayTypes(seed) if (seed.length !== crypto_sign_SEEDBYTES) @@ -825,7 +825,7 @@ const n = () => { scalarbase(p, hash) pack(pk, p) - return { publicKey: pk } + return hexify(pk) } return { sign, open, detached, verify, convert } -- 2.34.1