File tree Expand file tree Collapse file tree 1 file changed +14
-15
lines changed Expand file tree Collapse file tree 1 file changed +14
-15
lines changed Original file line number Diff line number Diff 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/**
You can’t perform that action at this time.
0 commit comments