@@ -462,7 +462,7 @@ macro_rules! sig_variant_impl {
462
462
}
463
463
464
464
pub fn uncompress( pk_comp: & [ u8 ] ) -> Result <Self , BLST_ERROR > {
465
- if pk_comp. len( ) == $pk_comp_size {
465
+ if pk_comp. len( ) == $pk_comp_size && ( pk_comp [ 0 ] & 0x80 ) != 0 {
466
466
let mut pk = <$pk_aff>:: default ( ) ;
467
467
let err = unsafe { $pk_uncomp( & mut pk, pk_comp. as_ptr( ) ) } ;
468
468
if err != BLST_ERROR :: BLST_SUCCESS {
@@ -475,8 +475,8 @@ macro_rules! sig_variant_impl {
475
475
}
476
476
477
477
pub fn deserialize( pk_in: & [ u8 ] ) -> Result <Self , BLST_ERROR > {
478
- if pk_in. len( ) == $pk_ser_size && ( pk_in[ 0 ] & 0x80 ) == 0
479
- || pk_in. len( ) == $pk_comp_size && ( pk_in[ 0 ] & 0x80 ) != 0
478
+ if ( pk_in. len( ) == $pk_ser_size && ( pk_in[ 0 ] & 0x80 ) == 0 )
479
+ || ( pk_in. len( ) == $pk_comp_size && ( pk_in[ 0 ] & 0x80 ) != 0 )
480
480
{
481
481
let mut pk = <$pk_aff>:: default ( ) ;
482
482
let err = unsafe { $pk_deser( & mut pk, pk_in. as_ptr( ) ) } ;
@@ -490,13 +490,7 @@ macro_rules! sig_variant_impl {
490
490
}
491
491
492
492
pub fn from_bytes( pk_in: & [ u8 ] ) -> Result <Self , BLST_ERROR > {
493
- if ( pk_in[ 0 ] & 0x80 ) == 0 {
494
- // Not compressed
495
- PublicKey :: deserialize( pk_in)
496
- } else {
497
- // compressed
498
- PublicKey :: uncompress( pk_in)
499
- }
493
+ PublicKey :: deserialize( pk_in)
500
494
}
501
495
502
496
pub fn to_bytes( & self ) -> [ u8 ; $pk_comp_size] {
@@ -552,7 +546,7 @@ macro_rules! sig_variant_impl {
552
546
let mut agg_pk = AggregatePublicKey :: from_public_key( pks[ 0 ] ) ;
553
547
for s in pks. iter( ) . skip( 1 ) {
554
548
if pks_validate {
555
- pks [ 0 ] . validate( ) ?;
549
+ s . validate( ) ?;
556
550
}
557
551
unsafe {
558
552
$pk_add_or_dbl_aff(
@@ -952,7 +946,7 @@ macro_rules! sig_variant_impl {
952
946
}
953
947
954
948
pub fn uncompress( sig_comp: & [ u8 ] ) -> Result <Self , BLST_ERROR > {
955
- if sig_comp. len( ) == $sig_comp_size {
949
+ if sig_comp. len( ) == $sig_comp_size && ( sig_comp [ 0 ] & 0x80 ) != 0 {
956
950
let mut sig = <$sig_aff>:: default ( ) ;
957
951
let err =
958
952
unsafe { $sig_uncomp( & mut sig, sig_comp. as_ptr( ) ) } ;
@@ -966,8 +960,8 @@ macro_rules! sig_variant_impl {
966
960
}
967
961
968
962
pub fn deserialize( sig_in: & [ u8 ] ) -> Result <Self , BLST_ERROR > {
969
- if sig_in. len( ) == $sig_ser_size && ( sig_in[ 0 ] & 0x80 ) == 0
970
- || sig_in. len( ) == $sig_comp_size && ( sig_in[ 0 ] & 0x80 ) != 0
963
+ if ( sig_in. len( ) == $sig_ser_size && ( sig_in[ 0 ] & 0x80 ) == 0 )
964
+ || ( sig_in. len( ) == $sig_comp_size && ( sig_in[ 0 ] & 0x80 ) != 0 )
971
965
{
972
966
let mut sig = <$sig_aff>:: default ( ) ;
973
967
let err = unsafe { $sig_deser( & mut sig, sig_in. as_ptr( ) ) } ;
@@ -981,13 +975,7 @@ macro_rules! sig_variant_impl {
981
975
}
982
976
983
977
pub fn from_bytes( sig_in: & [ u8 ] ) -> Result <Self , BLST_ERROR > {
984
- if ( sig_in[ 0 ] & 0x80 ) == 0 {
985
- // Not compressed
986
- Signature :: deserialize( sig_in)
987
- } else {
988
- // compressed
989
- Signature :: uncompress( sig_in)
990
- }
978
+ Signature :: deserialize( sig_in)
991
979
}
992
980
993
981
pub fn to_bytes( & self ) -> [ u8 ; $sig_comp_size] {
0 commit comments