@@ -204,16 +204,19 @@ class P1_Affine {
204
204
}
205
205
#endif
206
206
P1_Affine (const byte *in, size_t len)
207
- { if (len == 0 || len != (in[0 ]&0x80 ? 48 : 96 ))
207
+ { if (len == 0 || ( len != (in[0 ]&0x80 ? 48 : 96 ) && len != 128 ))
208
208
throw BLST_BAD_ENCODING;
209
- BLST_ERROR err = blst_p1_deserialize (&point, in);
209
+ BLST_ERROR err = len == 128 ? blst_p1_deserialize_eip2537 (&point, in)
210
+ : blst_p1_deserialize (&point, in);
210
211
if (err != BLST_SUCCESS)
211
212
throw err;
212
213
}
213
214
P1_Affine (const P1& jacobian);
214
215
215
216
P1_Affine dup () const { return *this ; }
216
217
P1 to_jacobian () const ;
218
+ void serialize_eip2537 (byte out[128 ]) const
219
+ { blst_p1_affine_serialize_eip2537 (out, &point); }
217
220
void serialize (byte out[96 ]) const
218
221
{ blst_p1_affine_serialize (out, &point); }
219
222
void compress (byte out[48 ]) const
@@ -264,18 +267,15 @@ class P1 {
264
267
}
265
268
#endif
266
269
P1 (const byte *in, size_t len)
267
- { if (len == 0 || len != (in[0 ]&0x80 ? 48 : 96 ))
268
- throw BLST_BAD_ENCODING;
269
- blst_p1_affine a;
270
- BLST_ERROR err = blst_p1_deserialize (&a, in);
271
- if (err != BLST_SUCCESS)
272
- throw err;
273
- blst_p1_from_affine (&point, &a);
270
+ { P1_Affine affine{in, len};
271
+ blst_p1_from_affine (&point, &affine.point );
274
272
}
275
273
P1 (const P1_Affine& affine) { blst_p1_from_affine (&point, affine); }
276
274
277
275
P1 dup () const { return *this ; }
278
276
P1_Affine to_affine () const { return P1_Affine (*this ); }
277
+ void serialize_eip2537 (byte out[128 ]) const
278
+ { blst_p1_serialize_eip2537 (out, &point); }
279
279
void serialize (byte out[96 ]) const { blst_p1_serialize (out, &point); }
280
280
void compress (byte out[48 ]) const { blst_p1_compress (out, &point); }
281
281
bool on_curve () const { return blst_p1_on_curve (&point); }
@@ -502,16 +502,19 @@ class P2_Affine {
502
502
}
503
503
#endif
504
504
P2_Affine (const byte *in, size_t len)
505
- { if (len == 0 || len != (in[0 ]&0x80 ? 96 : 192 ))
505
+ { if (len == 0 || ( len != (in[0 ]&0x80 ? 96 : 192 ) && len != 256 ))
506
506
throw BLST_BAD_ENCODING;
507
- BLST_ERROR err = blst_p2_deserialize (&point, in);
507
+ BLST_ERROR err = len == 256 ? blst_p2_deserialize_eip2537 (&point, in)
508
+ : blst_p2_deserialize (&point, in);
508
509
if (err != BLST_SUCCESS)
509
510
throw err;
510
511
}
511
512
P2_Affine (const P2& jacobian);
512
513
513
514
P2_Affine dup () const { return *this ; }
514
515
P2 to_jacobian () const ;
516
+ void serialize_eip2537 (byte out[256 ]) const
517
+ { blst_p2_affine_serialize_eip2537 (out, &point); }
515
518
void serialize (byte out[192 ]) const
516
519
{ blst_p2_affine_serialize (out, &point); }
517
520
void compress (byte out[96 ]) const
@@ -562,18 +565,15 @@ class P2 {
562
565
}
563
566
#endif
564
567
P2 (const byte *in, size_t len)
565
- { if (len == 0 || len != (in[0 ]&0x80 ? 96 : 192 ))
566
- throw BLST_BAD_ENCODING;
567
- blst_p2_affine a;
568
- BLST_ERROR err = blst_p2_deserialize (&a, in);
569
- if (err != BLST_SUCCESS)
570
- throw err;
571
- blst_p2_from_affine (&point, &a);
568
+ { P2_Affine affine{in, len};
569
+ blst_p2_from_affine (&point, &affine.point );
572
570
}
573
571
P2 (const P2_Affine& affine) { blst_p2_from_affine (&point, affine); }
574
572
575
573
P2 dup () const { return *this ; }
576
574
P2_Affine to_affine () const { return P2_Affine (*this ); }
575
+ void serialize_eip2537 (byte out[256 ]) const
576
+ { blst_p2_serialize (out, &point); }
577
577
void serialize (byte out[192 ]) const { blst_p2_serialize (out, &point); }
578
578
void compress (byte out[96 ]) const { blst_p2_compress (out, &point); }
579
579
bool on_curve () const { return blst_p2_on_curve (&point); }
0 commit comments