]> zoso.dev Git - libnemo.git/commitdiff
Fix call to wrong function for getting a signature rather than the signed message...
authorChris Duncan <chris@zoso.dev>
Wed, 4 Dec 2024 14:30:04 +0000 (06:30 -0800)
committerChris Duncan <chris@zoso.dev>
Thu, 5 Dec 2024 13:27:10 +0000 (05:27 -0800)
src/lib/block.ts
src/lib/tools.ts

index 36dda5ab79af85a35a5343582a56e0894df2bcea..ccb7cfd6d4e5d6d249b1b43d602fa5bbfca6c4df 100644 (file)
@@ -4,7 +4,7 @@
 import { BURN_ADDRESS, PREAMBLE, THRESHOLD_RECEIVE, THRESHOLD_SEND } from './constants.js'
 import { Account } from './account.js'
 import { Blake2b } from './blake2b.js'
-import { bytes, dec, hex } from './convert.js'
+import { dec, hex } from './convert.js'
 import { NanoNaCl } from './nano-nacl.js'
 import { Pool } from './pool.js'
 import { Rpc } from './rpc.js'
@@ -141,11 +141,11 @@ abstract class Block {
                        }
                        const account = await Account.fromPrivateKey(key)
                        try {
-                               const signature = NanoNaCl.sign(
+                               const signature = NanoNaCl.detached(
                                        hex.toBytes(await this.hash()),
                                        hex.toBytes(`${account.privateKey}${account.publicKey}`)
                                )
-                               this.signature = bytes.toHex(signature.subarray(0, 64))
+                               this.signature = signature
                        } catch (err) {
                                throw new Error(`Failed to sign block with key ${key}: ${err}`)
                        }
index d9146b44ebae9f7eca3dec93ea4b58e3e39d2381..5db26194713b3a4e0bdd34ce3f2a4dd3ad88da0e 100644 (file)
@@ -4,7 +4,7 @@
 import { Account } from './account.js'
 import { Blake2b } from './blake2b.js'
 import { UNITS } from './constants.js'
-import { bytes, hex } from './convert.js'
+import { hex } from './convert.js'
 import { Rpc } from './rpc.js'
 import { Bip44Wallet, Blake2bWallet, LedgerWallet } from './wallet.js'
 import { SendBlock } from './block.js'
@@ -82,10 +82,9 @@ export async function convert (amount: bigint | string, inputUnit: string, outpu
 export async function sign (key: string, ...input: string[]): Promise<string> {
        const account = await Account.fromPrivateKey(key)
        const data = hash(input)
-       const signature = NanoNaCl.sign(
+       return NanoNaCl.detached(
                hex.toBytes(data),
                hex.toBytes(`${account.privateKey}${account.publicKey}`))
-       return bytes.toHex(signature.subarray(0, 64))
 }
 
 /**