@@ -658,6 +658,147 @@ extern "C" {
658
658
hashfp : EllswiftEcdhHashFn ,
659
659
data : * mut c_void )
660
660
-> c_int ;
661
+
662
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_pubnonce_parse" ) ]
663
+ pub fn secp256k1_musig_pubnonce_parse (
664
+ cx : * const Context ,
665
+ nonce : * mut MusigPubNonce ,
666
+ in66 : * const c_uchar ,
667
+ ) -> c_int ;
668
+
669
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_pubnonce_serialize" ) ]
670
+ pub fn secp256k1_musig_pubnonce_serialize (
671
+ cx : * const Context ,
672
+ out66 : * mut c_uchar ,
673
+ nonce : * const MusigPubNonce ,
674
+ ) -> c_int ;
675
+
676
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_aggnonce_parse" ) ]
677
+ pub fn secp256k1_musig_aggnonce_parse (
678
+ cx : * const Context ,
679
+ nonce : * mut MusigAggNonce ,
680
+ in66 : * const c_uchar ,
681
+ ) -> c_int ;
682
+
683
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_aggnonce_serialize" ) ]
684
+ pub fn secp256k1_musig_aggnonce_serialize (
685
+ cx : * const Context ,
686
+ out66 : * mut c_uchar ,
687
+ nonce : * const MusigAggNonce ,
688
+ ) -> c_int ;
689
+
690
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_partial_sig_parse" ) ]
691
+ pub fn secp256k1_musig_partial_sig_parse (
692
+ cx : * const Context ,
693
+ sig : * mut MusigPartialSignature ,
694
+ in32 : * const c_uchar ,
695
+ ) -> c_int ;
696
+
697
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_partial_sig_serialize" ) ]
698
+ pub fn secp256k1_musig_partial_sig_serialize (
699
+ cx : * const Context ,
700
+ out32 : * mut c_uchar ,
701
+ sig : * const MusigPartialSignature ,
702
+ ) -> c_int ;
703
+
704
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_pubkey_agg" ) ]
705
+ pub fn secp256k1_musig_pubkey_agg (
706
+ cx : * const Context ,
707
+ agg_pk : * mut XOnlyPublicKey ,
708
+ keyagg_cache : * mut MusigKeyAggCache ,
709
+ pubkeys : * const * const PublicKey ,
710
+ n_pubkeys : size_t ,
711
+ ) -> c_int ;
712
+
713
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_pubkey_get" ) ]
714
+ pub fn secp256k1_musig_pubkey_get (
715
+ cx : * const Context ,
716
+ agg_pk : * mut PublicKey ,
717
+ keyagg_cache : * const MusigKeyAggCache ,
718
+ ) -> c_int ;
719
+
720
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_pubkey_ec_tweak_add" ) ]
721
+ pub fn secp256k1_musig_pubkey_ec_tweak_add (
722
+ cx : * const Context ,
723
+ output_pubkey : * mut PublicKey ,
724
+ keyagg_cache : * mut MusigKeyAggCache ,
725
+ tweak32 : * const c_uchar ,
726
+ ) -> c_int ;
727
+
728
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_pubkey_xonly_tweak_add" ) ]
729
+ pub fn secp256k1_musig_pubkey_xonly_tweak_add (
730
+ cx : * const Context ,
731
+ output_pubkey : * mut PublicKey ,
732
+ keyagg_cache : * mut MusigKeyAggCache ,
733
+ tweak32 : * const c_uchar ,
734
+ ) -> c_int ;
735
+
736
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_nonce_gen" ) ]
737
+ pub fn secp256k1_musig_nonce_gen (
738
+ cx : * const Context ,
739
+ secnonce : * mut MusigSecNonce ,
740
+ pubnonce : * mut MusigPubNonce ,
741
+ session_secrand32 : * const c_uchar ,
742
+ seckey : * const c_uchar ,
743
+ pubkey : * const PublicKey ,
744
+ msg32 : * const c_uchar ,
745
+ keyagg_cache : * const MusigKeyAggCache ,
746
+ extra_input32 : * const c_uchar ,
747
+ ) -> c_int ;
748
+
749
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_nonce_agg" ) ]
750
+ pub fn secp256k1_musig_nonce_agg (
751
+ cx : * const Context ,
752
+ aggnonce : * mut MusigAggNonce ,
753
+ pubnonces : * const * const MusigPubNonce ,
754
+ n_pubnonces : size_t ,
755
+ ) -> c_int ;
756
+
757
+
758
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_nonce_process" ) ]
759
+ pub fn secp256k1_musig_nonce_process (
760
+ cx : * const Context ,
761
+ session : * mut MusigSession ,
762
+ aggnonce : * const MusigAggNonce ,
763
+ msg32 : * const c_uchar ,
764
+ keyagg_cache : * const MusigKeyAggCache ,
765
+ ) -> c_int ;
766
+
767
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_partial_sign" ) ]
768
+ pub fn secp256k1_musig_partial_sign (
769
+ cx : * const Context ,
770
+ partial_sig : * mut MusigPartialSignature ,
771
+ secnonce : * mut MusigSecNonce ,
772
+ keypair : * const Keypair ,
773
+ keyagg_cache : * const MusigKeyAggCache ,
774
+ session : * const MusigSession ,
775
+ ) -> c_int ;
776
+
777
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_partial_sig_verify" ) ]
778
+ pub fn secp256k1_musig_partial_sig_verify (
779
+ cx : * const Context ,
780
+ partial_sig : * const MusigPartialSignature ,
781
+ pubnonce : * const MusigPubNonce ,
782
+ pubkey : * const PublicKey ,
783
+ keyagg_cache : * const MusigKeyAggCache ,
784
+ session : * const MusigSession ,
785
+ ) -> c_int ;
786
+
787
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_partial_sig_agg" ) ]
788
+ pub fn secp256k1_musig_partial_sig_agg (
789
+ cx : * const Context ,
790
+ sig64 : * mut c_uchar ,
791
+ session : * const MusigSession ,
792
+ partial_sigs : * const * const MusigPartialSignature ,
793
+ n_sigs : size_t ,
794
+ ) -> c_int ;
795
+
796
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_ec_pubkey_sort" ) ]
797
+ pub fn secp256k1_ec_pubkey_sort (
798
+ ctx : * const Context ,
799
+ pubkeys : * const * const PublicKey ,
800
+ n_pubkeys : size_t
801
+ ) -> c_int ;
661
802
}
662
803
663
804
#[ cfg( not( secp256k1_fuzz) ) ]
@@ -1084,6 +1225,162 @@ impl <T: CPtr> CPtr for Option<T> {
1084
1225
}
1085
1226
}
1086
1227
1228
+ pub const MUSIG_KEYAGG_LEN : usize = 197 ;
1229
+ pub const MUSIG_SECNONCE_LEN : usize = 132 ;
1230
+ pub const MUSIG_PUBNONCE_LEN : usize = 132 ;
1231
+ pub const MUSIG_AGGNONCE_LEN : usize = 132 ;
1232
+ pub const MUSIG_AGGNONCE_SERIALIZED_LEN : usize = 66 ;
1233
+ pub const MUSIG_PUBNONCE_SERIALIZED_LEN : usize = 66 ;
1234
+ pub const MUSIG_SESSION_LEN : usize = 133 ;
1235
+ pub const MUSIG_PART_SIG_LEN : usize = 36 ;
1236
+
1237
+ #[ repr( C ) ]
1238
+ #[ derive( Copy , Clone ) ]
1239
+ pub struct MusigKeyAggCache ( [ c_uchar ; MUSIG_KEYAGG_LEN ] ) ;
1240
+ impl_array_newtype ! ( MusigKeyAggCache , c_uchar, MUSIG_KEYAGG_LEN ) ;
1241
+ impl_raw_debug ! ( MusigKeyAggCache ) ;
1242
+
1243
+ #[ cfg( not( secp256k1_fuzz) ) ]
1244
+ impl PartialEq for MusigKeyAggCache {
1245
+ fn eq ( & self , other : & Self ) -> bool {
1246
+ self . 0 [ ..] == other. 0 [ ..]
1247
+ }
1248
+ }
1249
+
1250
+ #[ cfg( not( secp256k1_fuzz) ) ]
1251
+ impl Eq for MusigKeyAggCache { }
1252
+
1253
+ impl MusigKeyAggCache {
1254
+ pub fn new ( ) -> Self {
1255
+ MusigKeyAggCache ( [ 0 ; MUSIG_KEYAGG_LEN ] )
1256
+ }
1257
+ }
1258
+
1259
+
1260
+ #[ repr( C ) ]
1261
+ #[ derive( Copy , Clone ) ]
1262
+ pub struct MusigSecNonce ( pub ( crate ) [ c_uchar ; MUSIG_SECNONCE_LEN ] ) ;
1263
+ impl_array_newtype ! ( MusigSecNonce , c_uchar, MUSIG_SECNONCE_LEN ) ;
1264
+ impl_raw_debug ! ( MusigSecNonce ) ;
1265
+
1266
+ #[ cfg( not( secp256k1_fuzz) ) ]
1267
+ impl PartialEq for MusigSecNonce {
1268
+ fn eq ( & self , other : & Self ) -> bool {
1269
+ & self . 0 [ ..] == & other. 0 [ ..]
1270
+ }
1271
+ }
1272
+
1273
+ #[ cfg( not( secp256k1_fuzz) ) ]
1274
+ impl Eq for MusigSecNonce { }
1275
+
1276
+ impl MusigSecNonce {
1277
+ pub fn new ( ) -> Self {
1278
+ MusigSecNonce ( [ 0 ; MUSIG_SECNONCE_LEN ] )
1279
+ }
1280
+
1281
+ /// Don't use this. Refer to the documentation of wrapper APIs in the crate.
1282
+ //
1283
+ // No need for strong warning here, the user cannot use the ffi types directly in any of the APIs
1284
+ pub fn dangerous_from_bytes ( bytes : [ c_uchar ; MUSIG_SECNONCE_LEN ] ) -> Self {
1285
+ MusigSecNonce ( bytes)
1286
+ }
1287
+
1288
+ /// Don't use this. Refer to the documentation of wrapper APIs in the crate.
1289
+ //
1290
+ // No need for strong warning here, the user cannot use the ffi types directly in any of the high level APIs
1291
+ pub fn dangerous_into_bytes ( self ) -> [ c_uchar ; MUSIG_SECNONCE_LEN ] {
1292
+ self . 0
1293
+ }
1294
+ }
1295
+
1296
+ #[ repr( C ) ]
1297
+ #[ derive( Copy , Clone ) ]
1298
+ pub struct MusigPubNonce ( [ c_uchar ; MUSIG_PUBNONCE_LEN ] ) ;
1299
+ impl_array_newtype ! ( MusigPubNonce , c_uchar, MUSIG_PUBNONCE_LEN ) ;
1300
+ impl_raw_debug ! ( MusigPubNonce ) ;
1301
+
1302
+ #[ cfg( not( secp256k1_fuzz) ) ]
1303
+ impl PartialEq for MusigPubNonce {
1304
+ fn eq ( & self , other : & Self ) -> bool {
1305
+ & self . 0 [ ..] == & other. 0 [ ..]
1306
+ }
1307
+ }
1308
+
1309
+ #[ cfg( not( secp256k1_fuzz) ) ]
1310
+ impl Eq for MusigPubNonce { }
1311
+
1312
+ impl MusigPubNonce {
1313
+ pub fn new ( ) -> Self {
1314
+ MusigPubNonce ( [ 0 ; MUSIG_PUBNONCE_LEN ] )
1315
+ }
1316
+ }
1317
+
1318
+ #[ repr( C ) ]
1319
+ #[ derive( Copy , Clone ) ]
1320
+ pub struct MusigAggNonce ( [ c_uchar ; MUSIG_AGGNONCE_LEN ] ) ;
1321
+ impl_array_newtype ! ( MusigAggNonce , c_uchar, MUSIG_AGGNONCE_LEN ) ;
1322
+ impl_raw_debug ! ( MusigAggNonce ) ;
1323
+
1324
+ #[ cfg( not( secp256k1_fuzz) ) ]
1325
+ impl PartialEq for MusigAggNonce {
1326
+ fn eq ( & self , other : & Self ) -> bool {
1327
+ & self . 0 [ ..] == & other. 0 [ ..]
1328
+ }
1329
+ }
1330
+
1331
+ #[ cfg( not( secp256k1_fuzz) ) ]
1332
+ impl Eq for MusigAggNonce { }
1333
+
1334
+ impl MusigAggNonce {
1335
+ pub fn new ( ) -> Self {
1336
+ MusigAggNonce ( [ 0 ; MUSIG_AGGNONCE_LEN ] )
1337
+ }
1338
+ }
1339
+
1340
+ #[ repr( C ) ]
1341
+ #[ derive( Copy , Clone ) ]
1342
+ pub struct MusigSession ( [ c_uchar ; MUSIG_SESSION_LEN ] ) ;
1343
+ impl_array_newtype ! ( MusigSession , c_uchar, MUSIG_SESSION_LEN ) ;
1344
+ impl_raw_debug ! ( MusigSession ) ;
1345
+
1346
+ #[ cfg( not( secp256k1_fuzz) ) ]
1347
+ impl PartialEq for MusigSession {
1348
+ fn eq ( & self , other : & Self ) -> bool {
1349
+ & self . 0 [ ..] == & other. 0 [ ..]
1350
+ }
1351
+ }
1352
+
1353
+ #[ cfg( not( secp256k1_fuzz) ) ]
1354
+ impl Eq for MusigSession { }
1355
+
1356
+ impl MusigSession {
1357
+ pub fn new ( ) -> Self {
1358
+ MusigSession ( [ 0 ; MUSIG_SESSION_LEN ] )
1359
+ }
1360
+ }
1361
+
1362
+ #[ repr( C ) ]
1363
+ #[ derive( Copy , Clone ) ]
1364
+ pub struct MusigPartialSignature ( [ c_uchar ; MUSIG_PART_SIG_LEN ] ) ;
1365
+ impl_array_newtype ! ( MusigPartialSignature , c_uchar, MUSIG_PART_SIG_LEN ) ;
1366
+ impl_raw_debug ! ( MusigPartialSignature ) ;
1367
+
1368
+ #[ cfg( not( secp256k1_fuzz) ) ]
1369
+ impl PartialEq for MusigPartialSignature {
1370
+ fn eq ( & self , other : & Self ) -> bool {
1371
+ & self . 0 [ ..] == & other. 0 [ ..]
1372
+ }
1373
+ }
1374
+
1375
+ #[ cfg( not( secp256k1_fuzz) ) ]
1376
+ impl Eq for MusigPartialSignature { }
1377
+
1378
+ impl MusigPartialSignature {
1379
+ pub fn new ( ) -> Self {
1380
+ MusigPartialSignature ( [ 0 ; MUSIG_PART_SIG_LEN ] )
1381
+ }
1382
+ }
1383
+
1087
1384
#[ cfg( secp256k1_fuzz) ]
1088
1385
mod fuzz_dummy {
1089
1386
use super :: * ;
0 commit comments