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