@@ -82,6 +82,16 @@ pub type SchnorrNonceFn = Option<unsafe extern "C" fn(
82
82
data : * mut c_void ,
83
83
) -> c_int > ;
84
84
85
+ pub type EllswiftECDHHashFn = Option <
86
+ unsafe extern "C" fn (
87
+ output : * mut c_uchar ,
88
+ x32 : * const c_uchar ,
89
+ ell_a64 : * const c_uchar ,
90
+ ell_b64 : * const c_uchar ,
91
+ data : * mut c_void ,
92
+ ) -> c_int ,
93
+ > ;
94
+
85
95
/// Data structure that contains additional arguments for schnorrsig_sign_custom.
86
96
#[ repr( C ) ]
87
97
pub struct SchnorrSigExtraParams {
@@ -517,11 +527,44 @@ impl core::hash::Hash for Keypair {
517
527
}
518
528
}
519
529
530
+ pub struct XOnlySharedSecret ( pub [ u8 ; 32 ] ) ;
531
+
532
+ impl XOnlySharedSecret {
533
+ pub fn as_bytes ( & self ) -> & [ u8 ] {
534
+ & self . 0
535
+ }
536
+ pub fn as_mut_bytes ( & mut self ) -> & mut [ u8 ] {
537
+ & mut self . 0
538
+ }
539
+ }
540
+
541
+ impl_array_newtype ! ( XOnlySharedSecret , u8 , 32 ) ;
542
+ impl_raw_debug ! ( XOnlySharedSecret ) ;
543
+
544
+ #[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
545
+ pub struct ElligatorSwift ( [ u8 ; 64 ] ) ;
546
+
547
+ impl ElligatorSwift {
548
+ pub fn from_array ( arr : [ u8 ; 64 ] ) -> Self {
549
+ ElligatorSwift ( arr)
550
+ }
551
+ pub fn into_array ( self ) -> [ u8 ; 64 ] {
552
+ self . 0
553
+ }
554
+ }
555
+
556
+ impl_array_newtype ! ( ElligatorSwift , u8 , 64 ) ;
557
+ impl_raw_debug ! ( ElligatorSwift ) ;
558
+
520
559
extern "C" {
521
560
/// Default ECDH hash function
522
561
#[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_9_0_ecdh_hash_function_default" ) ]
523
562
pub static secp256k1_ecdh_hash_function_default: EcdhHashFn ;
524
563
564
+ /// Default ECDH hash function for BIP324 key establishment
565
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_9_0_ellswift_xdh_hash_function_bip324" ) ]
566
+ pub static secp256k1_ellswift_xdh_hash_function_bip324: EllswiftECDHHashFn ;
567
+
525
568
#[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_9_0_nonce_function_rfc6979" ) ]
526
569
pub static secp256k1_nonce_function_rfc6979: NonceFn ;
527
570
@@ -600,6 +643,38 @@ extern "C" {
600
643
output_pubkey : * mut PublicKey ,
601
644
keypair : * const Keypair )
602
645
-> c_int ;
646
+ // Elligator Swift
647
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_9_0_ellswift_encode" ) ]
648
+ pub fn secp256k1_ellswift_encode (
649
+ ctx : * const Context ,
650
+ ell64 : * mut c_uchar ,
651
+ pubkey : * const PublicKey ,
652
+ rnd32 : * const c_uchar ,
653
+ ) -> c_int ;
654
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_9_0_ellswift_decode" ) ]
655
+ pub fn secp256k1_ellswift_decode (
656
+ ctx : * const Context ,
657
+ pubkey : * mut u8 ,
658
+ ell64 : * const c_uchar ,
659
+ ) -> c_int ;
660
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_9_0_ellswift_create" ) ]
661
+ pub fn secp256k1_ellswift_create (
662
+ ctx : * const Context ,
663
+ ell64 : * mut c_uchar ,
664
+ seckey32 : * const c_uchar ,
665
+ aux_rand32 : * const c_uchar ,
666
+ ) -> c_int ;
667
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_9_0_ellswift_xdh" ) ]
668
+ pub fn secp256k1_ellswift_xdh (
669
+ ctx : * const Context ,
670
+ output : * mut c_uchar ,
671
+ ell_a64 : * const c_uchar ,
672
+ ell_b64 : * const c_uchar ,
673
+ seckey32 : * const c_uchar ,
674
+ party : c_int ,
675
+ hashfp : EllswiftECDHHashFn ,
676
+ data : * mut c_void ,
677
+ ) -> c_int ;
603
678
}
604
679
605
680
#[ cfg( not( secp256k1_fuzz) ) ]
0 commit comments