@@ -1617,35 +1617,38 @@ impl<'de> serde::Deserialize<'de> for XOnlyPublicKey {
1617
1617
}
1618
1618
}
1619
1619
1620
- /// Sort public keys using lexicographic (of compressed serialization) order.
1621
- /// Example:
1622
- ///
1623
- /// ```rust
1624
- /// # # [cfg(any(test, feature = "rand-std"))] {
1625
- /// # use secp256k1::rand::{rng, RngCore};
1626
- /// # use secp256k1::{Secp256k1, SecretKey, Keypair, PublicKey, pubkey_sort};
1627
- /// # let secp = Secp256k1::new();
1628
- /// # let sk1 = SecretKey::new(&mut rng());
1629
- /// # let pub_key1 = PublicKey::from_secret_key(&secp, &sk1);
1630
- /// # let sk2 = SecretKey::new(&mut rng());
1631
- /// # let pub_key2 = PublicKey::from_secret_key(&secp, &sk2);
1632
- /// #
1633
- /// # let pubkeys = [pub_key1, pub_key2];
1634
- /// # let mut pubkeys_ref: Vec<&PublicKey> = pubkeys.iter().collect();
1635
- /// # let pubkeys_ref = pubkeys_ref.as_mut_slice();
1636
- /// #
1637
- /// # pubkey_sort(&secp, pubkeys_ref);
1638
- /// # }
1639
- /// ```
1640
- pub fn pubkey_sort < C : Verification > ( secp : & Secp256k1 < C > , pubkeys : & mut [ & PublicKey ] ) {
1641
- let cx = secp. ctx ( ) . as_ptr ( ) ;
1642
- unsafe {
1643
- let mut pubkeys_ref = core:: slice:: from_raw_parts (
1644
- pubkeys. as_c_ptr ( ) as * mut * const ffi:: PublicKey ,
1645
- pubkeys. len ( ) ,
1646
- ) ;
1647
- if secp256k1_ec_pubkey_sort ( cx, pubkeys_ref. as_mut_c_ptr ( ) , pubkeys_ref. len ( ) ) == 0 {
1648
- unreachable ! ( "Invalid public keys for sorting function" )
1620
+ impl < C : Verification > Secp256k1 < C > {
1621
+ /// Sort public keys using lexicographic (of compressed serialization) order.
1622
+ ///
1623
+ /// Example:
1624
+ ///
1625
+ /// ```rust
1626
+ /// # # [cfg(any(test, feature = "rand-std"))] {
1627
+ /// # use secp256k1::rand::{rng, RngCore};
1628
+ /// # use secp256k1::{Secp256k1, SecretKey, Keypair, PublicKey, pubkey_sort};
1629
+ /// # let secp = Secp256k1::new();
1630
+ /// # let sk1 = SecretKey::new(&mut rng());
1631
+ /// # let pub_key1 = PublicKey::from_secret_key(&secp, &sk1);
1632
+ /// # let sk2 = SecretKey::new(&mut rng());
1633
+ /// # let pub_key2 = PublicKey::from_secret_key(&secp, &sk2);
1634
+ /// #
1635
+ /// # let pubkeys = [pub_key1, pub_key2];
1636
+ /// # let mut pubkeys_ref: Vec<&PublicKey> = pubkeys.iter().collect();
1637
+ /// # let pubkeys_ref = pubkeys_ref.as_mut_slice();
1638
+ /// #
1639
+ /// # secp.musig_sort_pubkeys(pubkeys_ref);
1640
+ /// # }
1641
+ /// ```
1642
+ pub fn musig_sort_pubkeys ( & self , pubkeys : & mut [ & PublicKey ] ) {
1643
+ let cx = self . ctx ( ) . as_ptr ( ) ;
1644
+ unsafe {
1645
+ let mut pubkeys_ref = core:: slice:: from_raw_parts (
1646
+ pubkeys. as_c_ptr ( ) as * mut * const ffi:: PublicKey ,
1647
+ pubkeys. len ( ) ,
1648
+ ) ;
1649
+ if secp256k1_ec_pubkey_sort ( cx, pubkeys_ref. as_mut_c_ptr ( ) , pubkeys_ref. len ( ) ) == 0 {
1650
+ unreachable ! ( "Invalid public keys for sorting function" )
1651
+ }
1649
1652
}
1650
1653
}
1651
1654
}
0 commit comments