@@ -82,6 +82,15 @@ pub type SchnorrNonceFn = Option<unsafe extern "C" fn(
82
82
data : * mut c_void ,
83
83
) -> c_int > ;
84
84
85
+ /// A hash function used by `ellswift_ecdh` to hash the final ECDH shared secret.
86
+ pub type EllswiftEcdhHashFn = Option < 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
+
85
94
/// Data structure that contains additional arguments for schnorrsig_sign_custom.
86
95
#[ repr( C ) ]
87
96
pub struct SchnorrSigExtraParams {
@@ -517,11 +526,32 @@ impl core::hash::Hash for Keypair {
517
526
}
518
527
}
519
528
529
+ /// Library-internal representation of a ElligatorSwift encoded group element.
530
+ #[ repr( C ) ]
531
+ #[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
532
+ pub struct ElligatorSwift ( [ u8 ; 64 ] ) ;
533
+
534
+ impl ElligatorSwift {
535
+ pub fn from_array ( arr : [ u8 ; 64 ] ) -> Self {
536
+ ElligatorSwift ( arr)
537
+ }
538
+ pub fn to_array ( self ) -> [ u8 ; 64 ] {
539
+ self . 0
540
+ }
541
+ }
542
+
543
+ impl_array_newtype ! ( ElligatorSwift , u8 , 64 ) ;
544
+ impl_raw_debug ! ( ElligatorSwift ) ;
545
+
520
546
extern "C" {
521
547
/// Default ECDH hash function
522
548
#[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_9_0_ecdh_hash_function_default" ) ]
523
549
pub static secp256k1_ecdh_hash_function_default: EcdhHashFn ;
524
550
551
+ /// Default ECDH hash function for BIP324 key establishment
552
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_9_0_ellswift_xdh_hash_function_bip324" ) ]
553
+ pub static secp256k1_ellswift_xdh_hash_function_bip324: EllswiftEcdhHashFn ;
554
+
525
555
#[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_9_0_nonce_function_rfc6979" ) ]
526
556
pub static secp256k1_nonce_function_rfc6979: NonceFn ;
527
557
@@ -600,6 +630,34 @@ extern "C" {
600
630
output_pubkey : * mut PublicKey ,
601
631
keypair : * const Keypair )
602
632
-> c_int ;
633
+ // Elligator Swift
634
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_9_0_ellswift_encode" ) ]
635
+ pub fn secp256k1_ellswift_encode ( ctx : * const Context ,
636
+ ell64 : * mut c_uchar ,
637
+ pubkey : * const PublicKey ,
638
+ rnd32 : * const c_uchar )
639
+ -> c_int ;
640
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_9_0_ellswift_decode" ) ]
641
+ pub fn secp256k1_ellswift_decode ( ctx : * const Context ,
642
+ pubkey : * mut u8 ,
643
+ ell64 : * const c_uchar )
644
+ -> c_int ;
645
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_9_0_ellswift_create" ) ]
646
+ pub fn secp256k1_ellswift_create ( ctx : * const Context ,
647
+ ell64 : * mut c_uchar ,
648
+ seckey32 : * const c_uchar ,
649
+ aux_rand32 : * const c_uchar )
650
+ -> c_int ;
651
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_9_0_ellswift_xdh" ) ]
652
+ pub fn secp256k1_ellswift_xdh ( ctx : * const Context ,
653
+ output : * mut c_uchar ,
654
+ ell_a64 : * const c_uchar ,
655
+ ell_b64 : * const c_uchar ,
656
+ seckey32 : * const c_uchar ,
657
+ party : c_int ,
658
+ hashfp : EllswiftEcdhHashFn ,
659
+ data : * mut c_void )
660
+ -> c_int ;
603
661
}
604
662
605
663
#[ cfg( not( secp256k1_fuzz) ) ]
0 commit comments