From: Chris Duncan Date: Tue, 3 Dec 2024 22:38:23 +0000 (-0800) Subject: Return public key as hex string from NanoNaCl. X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=3ddb1840b34770dd08cb9a1ff90297ee8010de16;p=libnemo.git Return public key as hex string from NanoNaCl. --- 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 }