Skip to content

Commit 407682a

Browse files
committed
feat(bls): remove case 218 as we don't use it
1 parent b9b0ca1 commit 407682a

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
@@ -128,22 +128,21 @@ export const encrypt = (
128128
* while G1 is associated with encryption. Here, the length of the public key determines how
129129
* we handle the encryption and the format of the returned encrypted message.
130130
*/
131-
switch (publicKeyHex.replace('0x', '').length) {
132-
133-
/**
134-
* @deprecated - not sure if this is still used/needed
135-
*/
136-
case 218:
137-
return Buffer.from(
138-
await blsEncrypt('Bls12381G2', publicKey, message, identity)
139-
).toString('hex');
140-
case 96:
141-
return Buffer.from(
142-
await blsEncrypt('Bls12381G2', publicKey, message, identity)
143-
).toString('base64');
144-
default:
145-
return '';
131+
132+
if (publicKeyHex.replace('0x', '').length !== 96) {
133+
throw new InvalidParamType(
134+
{
135+
info: {
136+
publicKeyHex,
137+
},
138+
},
139+
`Invalid public key length. Expecting 96 characters, got ${publicKeyHex.replace('0x', '').length} instead.`
140+
);
146141
}
142+
return Buffer.from(
143+
await blsEncrypt('Bls12381G2', publicKey, message, identity)
144+
).toString('base64');
145+
147146
};
148147

149148
/**

0 commit comments

Comments
 (0)