From 5e2932cbe8687da6e74eb8308c545378f34347ff Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Tue, 3 Dec 2024 23:08:55 -0800 Subject: [PATCH] If signature verification fails due to an error, log the error and return false to the calling function. --- src/lib/tools.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lib/tools.ts b/src/lib/tools.ts index cff52bf..d9146b4 100644 --- a/src/lib/tools.ts +++ b/src/lib/tools.ts @@ -153,10 +153,15 @@ export async function sweep (rpc: Rpc | string | URL, wallet: Blake2bWallet | Bi */ export async function verify (key: string, signature: string, ...input: string[]): Promise { const data = hash(input) - return NanoNaCl.verify( - hex.toBytes(data), - hex.toBytes(signature), - hex.toBytes(key)) + try { + return await NanoNaCl.verify( + hex.toBytes(data), + hex.toBytes(signature), + hex.toBytes(key)) + } catch (err) { + console.error(err) + return false + } } export const Tools = { convert, sign, sweep, verify } -- 2.34.1