From 9e220483bb3a399608cfdb68db61647bbfb7d955 Mon Sep 17 00:00:00 2001 From: Brian Faust Date: Fri, 14 Jan 2022 08:01:07 +0200 Subject: [PATCH] chore(ark): log errors for keypair derivation --- packages/ark/source/crypto/identities/keys.ts | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/packages/ark/source/crypto/identities/keys.ts b/packages/ark/source/crypto/identities/keys.ts index 7b52c4af9..15b3a0a92 100644 --- a/packages/ark/source/crypto/identities/keys.ts +++ b/packages/ark/source/crypto/identities/keys.ts @@ -13,11 +13,22 @@ export class Keys { public static fromPrivateKey(privateKey: Buffer | string, compressed = true): KeyPair { privateKey = privateKey instanceof Buffer ? privateKey : Buffer.from(privateKey, "hex"); - return { - compressed, - privateKey: privateKey.toString("hex"), - publicKey: secp256k1.publicKeyCreate(privateKey, compressed).toString("hex"), - }; + try { + return { + compressed, + privateKey: privateKey.toString("hex"), + publicKey: secp256k1.publicKeyCreate(privateKey, compressed).toString("hex"), + }; + } catch (error) { + console.error({ + error, + message: error.message, + privateKeLength: privateKey.length, + privateKey, + }); + + throw error; + } } public static fromWIF(wif: string, network?: Network): KeyPair {