]> zoso.dev Git - libnemo.git/commitdiff
Return public key as hex string from NanoNaCl.
authorChris Duncan <chris@zoso.dev>
Tue, 3 Dec 2024 22:38:23 +0000 (14:38 -0800)
committerChris Duncan <chris@zoso.dev>
Tue, 3 Dec 2024 22:38:23 +0000 (14:38 -0800)
src/lib/account.ts
src/lib/nano-nacl.ts

index 3e4a9878d6f05326b5894532662e6f94889f3b08..f9d7d1df6c8d1e9367ddaa05e742656e34b69b93 100644 (file)
@@ -109,8 +109,8 @@ export class Account {
        static fromPrivateKey (privateKey: string, index?: number): Account {\r
                Account.#isInternal = true\r
                Account.#validateKey(privateKey)\r
-               const { publicKey } = NanoNaCl.convert(privateKey)\r
-               const account = Account.fromPublicKey(bytes.toHex(publicKey), index)\r
+               const publicKey = NanoNaCl.convert(privateKey)\r
+               const account = Account.fromPublicKey(publicKey, index)\r
                account.#prv = privateKey.toUpperCase()\r
                return account\r
        }\r
index 9ff8e241ef49e46221dba9080265d9323604dab1..5338b20e7c0bba0bf45a8b07085b7055357c8bbc 100644 (file)
@@ -808,7 +808,7 @@ const n = () => {
                return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0)\r
        }\r
 \r
-       const convert = function (seed: string | Uint8Array) {\r
+       const convert = function (seed: string | Uint8Array): string {\r
                if (typeof seed === 'string') seed = parseHex(seed)\r
                checkArrayTypes(seed)\r
                if (seed.length !== crypto_sign_SEEDBYTES)\r
@@ -825,7 +825,7 @@ const n = () => {
                scalarbase(p, hash)\r
                pack(pk, p)\r
 \r
-               return { publicKey: pk }\r
+               return hexify(pk)\r
        }\r
 \r
        return { sign, open, detached, verify, convert }\r