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 @@ -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/**
You can’t perform that action at this time.
0 commit comments