Skip to content

Commit 5f4b017

Browse files
committed
feat(bls): remove case 218 as we don't use it
1 parent bc99122 commit 5f4b017

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

packages/crypto/src/lib/crypto.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,21 @@ export const encrypt = async (
6969
* while G1 is associated with encryption. Here, the length of the public key determines how
7070
* we handle the encryption and the format of the returned encrypted message.
7171
*/
72-
switch (publicKeyHex.replace('0x', '').length) {
73-
74-
/**
75-
* @deprecated - not sure if this is still used/needed
76-
*/
77-
case 218:
78-
return Buffer.from(
79-
await blsEncrypt('Bls12381G2', publicKey, message, identity)
80-
).toString('hex');
81-
case 96:
82-
return Buffer.from(
83-
await blsEncrypt('Bls12381G2', publicKey, message, identity)
84-
).toString('base64');
85-
default:
86-
return '';
72+
73+
if (publicKeyHex.replace('0x', '').length !== 96) {
74+
throw new InvalidParamType(
75+
{
76+
info: {
77+
publicKeyHex,
78+
},
79+
},
80+
`Invalid public key length. Expecting 96 characters, got ${publicKeyHex.replace('0x', '').length} instead.`
81+
);
8782
}
83+
return Buffer.from(
84+
await blsEncrypt('Bls12381G2', publicKey, message, identity)
85+
).toString('base64');
86+
8887
};
8988

9089
/**

0 commit comments

Comments
 (0)