From c7eea285e345f68185cc32abe5f27a82e671a312 Mon Sep 17 00:00:00 2001 From: danielntmd Date: Mon, 30 Mar 2026 20:48:59 +0000 Subject: [PATCH] chore: remove dead code, verify keypair During decryption `decryptBn254KeystoreFromObject` recomputes and validates that the checksum is correct, which is the key pair verification that makes this `verifyBn254Keypair` function obsolete. --- .../src/crypto/bls/bn254_keystore.ts | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/yarn-project/foundation/src/crypto/bls/bn254_keystore.ts b/yarn-project/foundation/src/crypto/bls/bn254_keystore.ts index 89ccc3845b72..88c8dd8932f2 100644 --- a/yarn-project/foundation/src/crypto/bls/bn254_keystore.ts +++ b/yarn-project/foundation/src/crypto/bls/bn254_keystore.ts @@ -262,26 +262,3 @@ export function decryptBn254KeystoreFromObject(keystore: Bn254Keystore, password throw new Bn254KeystoreError(`Failed to decrypt keystore: ${String(error)}`, error as Error); } } - -/** - * Validates that a decrypted private key matches the public key in the keystore. - * - * @param privateKeyHex - Decrypted private key (0x-prefixed) - * @param expectedPubkey - Expected public key from keystore - * @param computePublicKey - Function to compute public key from private key - * @returns true if keys match, false otherwise - */ -export function verifyBn254Keypair( - privateKeyHex: string, - expectedPubkey: string, - computePublicKey: (privateKey: string) => string, -): boolean { - try { - const computedPubkey = computePublicKey(privateKeyHex); - const normalizedExpected = expectedPubkey.toLowerCase().replace(/^0x/i, ''); - const normalizedComputed = computedPubkey.toLowerCase().replace(/^0x/i, ''); - return normalizedExpected === normalizedComputed; - } catch { - return false; - } -}