]> zoso.dev Git - libnemo.git/commitdiff
If signature verification fails due to an error, log the error and return false to...
authorChris Duncan <chris@zoso.dev>
Wed, 4 Dec 2024 07:08:55 +0000 (23:08 -0800)
committerChris Duncan <chris@zoso.dev>
Wed, 4 Dec 2024 07:08:55 +0000 (23:08 -0800)
src/lib/tools.ts

index cff52bf217cc220cc9191bbf22b88c623dfb15a3..d9146b44ebae9f7eca3dec93ea4b58e3e39d2381 100644 (file)
@@ -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<boolean> {
        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 }