@@ -14,7 +14,7 @@ use alloc::boxed::Box;
14
14
use alloc:: vec;
15
15
use alloc:: vec:: Vec ;
16
16
use core:: any:: Any ;
17
- use core:: mem:: MaybeUninit ;
17
+ use core:: mem:: { transmute , MaybeUninit } ;
18
18
use core:: ptr;
19
19
use zeroize:: Zeroize ;
20
20
@@ -34,7 +34,6 @@ trait ThreadPoolExt {
34
34
#[ cfg( all( not( feature = "no-threads" ) , feature = "std" ) ) ]
35
35
mod mt {
36
36
use super :: * ;
37
- use core:: mem:: transmute;
38
37
use std:: sync:: { Mutex , Once } ;
39
38
use threadpool:: ThreadPool ;
40
39
@@ -951,6 +950,21 @@ macro_rules! sig_variant_impl {
951
950
Ok ( agg_pk)
952
951
}
953
952
953
+ pub fn aggregate_with_randomness(
954
+ pks: & [ PublicKey ] ,
955
+ randomness: & [ u8 ] ,
956
+ nbits: usize ,
957
+ pks_groupcheck: bool ,
958
+ ) -> Result <Self , BLST_ERROR > {
959
+ if pks. len( ) == 0 {
960
+ return Err ( BLST_ERROR :: BLST_AGGR_TYPE_MISMATCH ) ;
961
+ }
962
+ if pks_groupcheck {
963
+ pks. validate( ) ?;
964
+ }
965
+ Ok ( pks. mult( randomness, nbits) )
966
+ }
967
+
954
968
pub fn aggregate_serialized(
955
969
pks: & [ & [ u8 ] ] ,
956
970
pks_validate: bool ,
@@ -1516,6 +1530,21 @@ macro_rules! sig_variant_impl {
1516
1530
Ok ( agg_sig)
1517
1531
}
1518
1532
1533
+ pub fn aggregate_with_randomness(
1534
+ sigs: & [ Signature ] ,
1535
+ randomness: & [ u8 ] ,
1536
+ nbits: usize ,
1537
+ sigs_groupcheck: bool ,
1538
+ ) -> Result <Self , BLST_ERROR > {
1539
+ if sigs. len( ) == 0 {
1540
+ return Err ( BLST_ERROR :: BLST_AGGR_TYPE_MISMATCH ) ;
1541
+ }
1542
+ if sigs_groupcheck {
1543
+ sigs. validate( ) ?;
1544
+ }
1545
+ Ok ( sigs. mult( randomness, nbits) )
1546
+ }
1547
+
1519
1548
pub fn aggregate_serialized(
1520
1549
sigs: & [ & [ u8 ] ] ,
1521
1550
sigs_groupcheck: bool ,
@@ -1585,43 +1614,43 @@ macro_rules! sig_variant_impl {
1585
1614
1586
1615
fn mult( & self , scalars: & [ u8 ] , nbits: usize ) -> Self :: Output {
1587
1616
Self :: Output {
1588
- point: unsafe {
1589
- core:: mem:: transmute:: <& [ _] , & [ $pk_aff] >( self )
1590
- }
1591
- . mult( scalars, nbits) ,
1617
+ point: unsafe { transmute:: <& [ _] , & [ $pk_aff] >( self ) }
1618
+ . mult( scalars, nbits) ,
1592
1619
}
1593
1620
}
1594
1621
1595
1622
fn add( & self ) -> Self :: Output {
1596
1623
Self :: Output {
1597
- point: unsafe {
1598
- core:: mem:: transmute:: <& [ _] , & [ $pk_aff] >( self )
1599
- }
1600
- . add( ) ,
1624
+ point: unsafe { transmute:: <& [ _] , & [ $pk_aff] >( self ) }
1625
+ . add( ) ,
1601
1626
}
1602
1627
}
1628
+
1629
+ fn validate( & self ) -> Result <( ) , BLST_ERROR > {
1630
+ unsafe { transmute:: <& [ _] , & [ $pk_aff] >( self ) } . validate( )
1631
+ }
1603
1632
}
1604
1633
1605
1634
impl MultiPoint for [ Signature ] {
1606
1635
type Output = AggregateSignature ;
1607
1636
1608
1637
fn mult( & self , scalars: & [ u8 ] , nbits: usize ) -> Self :: Output {
1609
1638
Self :: Output {
1610
- point: unsafe {
1611
- core:: mem:: transmute:: <& [ _] , & [ $sig_aff] >( self )
1612
- }
1613
- . mult( scalars, nbits) ,
1639
+ point: unsafe { transmute:: <& [ _] , & [ $sig_aff] >( self ) }
1640
+ . mult( scalars, nbits) ,
1614
1641
}
1615
1642
}
1616
1643
1617
1644
fn add( & self ) -> Self :: Output {
1618
1645
Self :: Output {
1619
- point: unsafe {
1620
- core:: mem:: transmute:: <& [ _] , & [ $sig_aff] >( self )
1621
- }
1622
- . add( ) ,
1646
+ point: unsafe { transmute:: <& [ _] , & [ $sig_aff] >( self ) }
1647
+ . add( ) ,
1623
1648
}
1624
1649
}
1650
+
1651
+ fn validate( & self ) -> Result <( ) , BLST_ERROR > {
1652
+ unsafe { transmute:: <& [ _] , & [ $sig_aff] >( self ) } . validate( )
1653
+ }
1625
1654
}
1626
1655
1627
1656
#[ cfg( test) ]
0 commit comments