From: Chris Duncan Date: Wed, 4 Dec 2024 07:08:55 +0000 (-0800) Subject: If signature verification fails due to an error, log the error and return false to... X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=5e2932cbe8687da6e74eb8308c545378f34347ff;p=libnemo.git If signature verification fails due to an error, log the error and return false to the calling function. --- 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 }