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