@@ -82,6 +82,16 @@ pub type SchnorrNonceFn = Option<unsafe extern "C" fn(
8282 data : * mut c_void ,
8383) -> c_int > ;
8484
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+
8595/// Data structure that contains additional arguments for schnorrsig_sign_custom.
8696#[ repr( C ) ]
8797pub struct SchnorrSigExtraParams {
@@ -517,11 +527,41 @@ impl core::hash::Hash for Keypair {
517527 }
518528}
519529
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+ }
552+
553+ impl_array_newtype ! ( ElligatorSwift , u8 , 64 ) ;
554+ impl_raw_debug ! ( ElligatorSwift ) ;
555+
520556extern "C" {
521557 /// Default ECDH hash function
522558 #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_9_0_ecdh_hash_function_default" ) ]
523559 pub static secp256k1_ecdh_hash_function_default: EcdhHashFn ;
524560
561+ /// Default ECDH hash function for BIP324 key establishment
562+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_9_0_ellswift_xdh_hash_function_bip324" ) ]
563+ pub static secp256k1_ellswift_xdh_hash_function_bip324: EllswiftECDHHashFn ;
564+
525565 #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_9_0_nonce_function_rfc6979" ) ]
526566 pub static secp256k1_nonce_function_rfc6979: NonceFn ;
527567
@@ -600,6 +640,38 @@ extern "C" {
600640 output_pubkey : * mut PublicKey ,
601641 keypair : * const Keypair )
602642 -> c_int ;
643+ // Elligator Swift
644+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_9_0_ellswift_encode" ) ]
645+ pub fn secp256k1_ellswift_encode (
646+ ctx : * const Context ,
647+ ell64 : * mut c_uchar ,
648+ pubkey : * const PublicKey ,
649+ rnd32 : * const c_uchar ,
650+ ) -> c_int ;
651+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_9_0_ellswift_decode" ) ]
652+ pub fn secp256k1_ellswift_decode (
653+ ctx : * const Context ,
654+ pubkey : * mut u8 ,
655+ ell64 : * const c_uchar ,
656+ ) -> c_int ;
657+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_9_0_ellswift_create" ) ]
658+ pub fn secp256k1_ellswift_create (
659+ ctx : * const Context ,
660+ ell64 : * mut c_uchar ,
661+ seckey32 : * const c_uchar ,
662+ aux_rand32 : * const c_uchar ,
663+ ) -> c_int ;
664+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_9_0_ellswift_xdh" ) ]
665+ pub fn secp256k1_ellswift_xdh (
666+ ctx : * const Context ,
667+ output : * mut c_uchar ,
668+ ell_a64 : * const c_uchar ,
669+ ell_b64 : * const c_uchar ,
670+ seckey32 : * const c_uchar ,
671+ party : c_int ,
672+ hashfp : EllswiftECDHHashFn ,
673+ data : * mut c_void ,
674+ ) -> c_int ;
603675}
604676
605677#[ cfg( not( secp256k1_fuzz) ) ]
0 commit comments