@@ -852,6 +852,147 @@ extern "C" {
852
852
internal_pubkey : * const XOnlyPublicKey ,
853
853
tweak32 : * const c_uchar ,
854
854
) -> c_int ;
855
+
856
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_pubnonce_parse" ) ]
857
+ pub fn secp256k1_musig_pubnonce_parse (
858
+ cx : * const Context ,
859
+ nonce : * mut MusigPubNonce ,
860
+ in66 : * const c_uchar ,
861
+ ) -> c_int ;
862
+
863
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_pubnonce_serialize" ) ]
864
+ pub fn secp256k1_musig_pubnonce_serialize (
865
+ cx : * const Context ,
866
+ out66 : * mut c_uchar ,
867
+ nonce : * const MusigPubNonce ,
868
+ ) -> c_int ;
869
+
870
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_aggnonce_parse" ) ]
871
+ pub fn secp256k1_musig_aggnonce_parse (
872
+ cx : * const Context ,
873
+ nonce : * mut MusigAggNonce ,
874
+ in66 : * const c_uchar ,
875
+ ) -> c_int ;
876
+
877
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_aggnonce_serialize" ) ]
878
+ pub fn secp256k1_musig_aggnonce_serialize (
879
+ cx : * const Context ,
880
+ out66 : * mut c_uchar ,
881
+ nonce : * const MusigAggNonce ,
882
+ ) -> c_int ;
883
+
884
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_partial_sig_parse" ) ]
885
+ pub fn secp256k1_musig_partial_sig_parse (
886
+ cx : * const Context ,
887
+ sig : * mut MusigPartialSignature ,
888
+ in32 : * const c_uchar ,
889
+ ) -> c_int ;
890
+
891
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_partial_sig_serialize" ) ]
892
+ pub fn secp256k1_musig_partial_sig_serialize (
893
+ cx : * const Context ,
894
+ out32 : * mut c_uchar ,
895
+ sig : * const MusigPartialSignature ,
896
+ ) -> c_int ;
897
+
898
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_pubkey_agg" ) ]
899
+ pub fn secp256k1_musig_pubkey_agg (
900
+ cx : * const Context ,
901
+ agg_pk : * mut XOnlyPublicKey ,
902
+ keyagg_cache : * mut MusigKeyAggCache ,
903
+ pubkeys : * const * const PublicKey ,
904
+ n_pubkeys : size_t ,
905
+ ) -> c_int ;
906
+
907
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_pubkey_get" ) ]
908
+ pub fn secp256k1_musig_pubkey_get (
909
+ cx : * const Context ,
910
+ agg_pk : * mut PublicKey ,
911
+ keyagg_cache : * const MusigKeyAggCache ,
912
+ ) -> c_int ;
913
+
914
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_pubkey_ec_tweak_add" ) ]
915
+ pub fn secp256k1_musig_pubkey_ec_tweak_add (
916
+ cx : * const Context ,
917
+ output_pubkey : * mut PublicKey ,
918
+ keyagg_cache : * mut MusigKeyAggCache ,
919
+ tweak32 : * const c_uchar ,
920
+ ) -> c_int ;
921
+
922
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_pubkey_xonly_tweak_add" ) ]
923
+ pub fn secp256k1_musig_pubkey_xonly_tweak_add (
924
+ cx : * const Context ,
925
+ output_pubkey : * mut PublicKey ,
926
+ keyagg_cache : * mut MusigKeyAggCache ,
927
+ tweak32 : * const c_uchar ,
928
+ ) -> c_int ;
929
+
930
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_nonce_gen" ) ]
931
+ pub fn secp256k1_musig_nonce_gen (
932
+ cx : * const Context ,
933
+ secnonce : * mut MusigSecNonce ,
934
+ pubnonce : * mut MusigPubNonce ,
935
+ session_secrand32 : * const c_uchar ,
936
+ seckey : * const c_uchar ,
937
+ pubkey : * const PublicKey ,
938
+ msg32 : * const c_uchar ,
939
+ keyagg_cache : * const MusigKeyAggCache ,
940
+ extra_input32 : * const c_uchar ,
941
+ ) -> c_int ;
942
+
943
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_nonce_agg" ) ]
944
+ pub fn secp256k1_musig_nonce_agg (
945
+ cx : * const Context ,
946
+ aggnonce : * mut MusigAggNonce ,
947
+ pubnonces : * const * const MusigPubNonce ,
948
+ n_pubnonces : size_t ,
949
+ ) -> c_int ;
950
+
951
+
952
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_nonce_process" ) ]
953
+ pub fn secp256k1_musig_nonce_process (
954
+ cx : * const Context ,
955
+ session : * mut MusigSession ,
956
+ aggnonce : * const MusigAggNonce ,
957
+ msg32 : * const c_uchar ,
958
+ keyagg_cache : * const MusigKeyAggCache ,
959
+ ) -> c_int ;
960
+
961
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_partial_sign" ) ]
962
+ pub fn secp256k1_musig_partial_sign (
963
+ cx : * const Context ,
964
+ partial_sig : * mut MusigPartialSignature ,
965
+ secnonce : * mut MusigSecNonce ,
966
+ keypair : * const Keypair ,
967
+ keyagg_cache : * const MusigKeyAggCache ,
968
+ session : * const MusigSession ,
969
+ ) -> c_int ;
970
+
971
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_partial_sig_verify" ) ]
972
+ pub fn secp256k1_musig_partial_sig_verify (
973
+ cx : * const Context ,
974
+ partial_sig : * const MusigPartialSignature ,
975
+ pubnonce : * const MusigPubNonce ,
976
+ pubkey : * const PublicKey ,
977
+ keyagg_cache : * const MusigKeyAggCache ,
978
+ session : * const MusigSession ,
979
+ ) -> c_int ;
980
+
981
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_musig_partial_sig_agg" ) ]
982
+ pub fn secp256k1_musig_partial_sig_agg (
983
+ cx : * const Context ,
984
+ sig64 : * mut c_uchar ,
985
+ session : * const MusigSession ,
986
+ partial_sigs : * const * const MusigPartialSignature ,
987
+ n_sigs : size_t ,
988
+ ) -> c_int ;
989
+
990
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_ec_pubkey_sort" ) ]
991
+ pub fn secp256k1_ec_pubkey_sort (
992
+ ctx : * const Context ,
993
+ pubkeys : * const * const PublicKey ,
994
+ n_pubkeys : size_t
995
+ ) -> c_int ;
855
996
}
856
997
857
998
/// A reimplementation of the C function `secp256k1_context_create` in rust.
@@ -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