From 706795d301065da8e28970c24ec3b9879ff4202a Mon Sep 17 00:00:00 2001 From: Bean Date: Mon, 29 Jan 2024 19:18:24 -0500 Subject: [PATCH] Fix/default crypto bug (#335) * fix default case in switch statement, and remove `0x` prefix from keys if present. * add in replace for auto formatting. --- packages/crypto/src/lib/crypto.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/crypto/src/lib/crypto.ts b/packages/crypto/src/lib/crypto.ts index b0809e3110..c155f90da1 100644 --- a/packages/crypto/src/lib/crypto.ts +++ b/packages/crypto/src/lib/crypto.ts @@ -298,8 +298,14 @@ export const computeHDPubKey = ( try { switch (sigType) { case SIGTYPE.EcdsaCaitSith: + // a bit of pre processing to remove characters which will cause our wasm module to reject the values. + pubkeys = pubkeys.map((value: string) => { + return value.replace('0x', ''); + }); + keyId = keyId.replace('0x', ''); return ecdsaSdk.compute_public_key(keyId, pubkeys, 2); - defualt: throw new Error('Non supported signature type'); + default: + throw new Error('Non supported signature type'); } } catch (e) { log('Failed to derive public key', e);