File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -74,17 +74,28 @@ internal static Scalar secp256k1_musig_keyaggcoef(MusigContext pre_session, ECPu
7474
7575 const string MusigTag = "KeyAgg coefficient" ;
7676
77- public static ECPubKey MusigAggregate ( ECPubKey [ ] pubkeys )
77+ /// <summary>
78+ /// Aggregate the public keys into a single one
79+ /// </summary>
80+ /// <param name="pubkeys">The public keys to aggregate</param>
81+ /// <param name="sort">If true, the pubkeys will be sorted before being aggregated</param>
82+ /// <returns></returns>
83+ public static ECPubKey MusigAggregate ( ECPubKey [ ] pubkeys , bool sort = false )
7884 {
79- return MusigAggregate ( pubkeys , null ) ;
85+ return MusigAggregate ( pubkeys , null , sort ) ;
8086 }
8187
82- internal static ECPubKey MusigAggregate ( ECPubKey [ ] pubkeys , MusigContext ? preSession )
88+ internal static ECPubKey MusigAggregate ( ECPubKey [ ] pubkeys , MusigContext ? preSession , bool sort )
8389 {
8490 if ( pubkeys == null )
8591 throw new ArgumentNullException ( nameof ( pubkeys ) ) ;
8692 if ( pubkeys . Length is 0 )
8793 throw new ArgumentNullException ( nameof ( pubkeys ) , "At least one pubkey should be passed" ) ;
94+ if ( sort )
95+ {
96+ pubkeys = pubkeys . ToArray ( ) ;
97+ Array . Sort ( pubkeys ) ;
98+ }
8899 /* No point on the curve has an X coordinate equal to 0 */
89100 var second_pk_x = FE . Zero ;
90101 for ( int i = 1 ; i < pubkeys . Length ; i ++ )
You can’t perform that action at this time.
0 commit comments