@@ -72,7 +72,7 @@ pub type EcdhHashFn = unsafe extern "C" fn(
72
72
x : * const c_uchar ,
73
73
y : * const c_uchar ,
74
74
data : * mut c_void ,
75
- ) ;
75
+ ) -> c_int ;
76
76
77
77
/// A Secp256k1 context, containing various precomputed values and such
78
78
/// needed to do elliptic curve computations. If you create one of these
@@ -134,25 +134,6 @@ impl Default for Signature {
134
134
}
135
135
}
136
136
137
- /// Library-internal representation of an ECDH shared secret
138
- #[ repr( C ) ]
139
- pub struct SharedSecret ( [ c_uchar ; 32 ] ) ;
140
- impl_array_newtype ! ( SharedSecret , c_uchar, 32 ) ;
141
- impl_raw_debug ! ( SharedSecret ) ;
142
-
143
- impl SharedSecret {
144
- /// Create a new (zeroed) signature usable for the FFI interface
145
- pub fn new ( ) -> SharedSecret { SharedSecret ( [ 0 ; 32 ] ) }
146
- /// Create a new (uninitialized) signature usable for the FFI interface
147
- #[ deprecated( since = "0.15.3" , note = "Please use the new function instead" ) ]
148
- pub unsafe fn blank ( ) -> SharedSecret { SharedSecret :: new ( ) }
149
- }
150
-
151
- impl Default for SharedSecret {
152
- fn default ( ) -> Self {
153
- SharedSecret :: new ( )
154
- }
155
- }
156
137
157
138
#[ cfg( not( feature = "fuzztarget" ) ) ]
158
139
extern "C" {
@@ -296,7 +277,7 @@ extern "C" {
296
277
#[ cfg_attr( not( feature = "external-symbols" ) , link_name = "rustsecp256k1_v0_1_0_ecdh" ) ]
297
278
pub fn secp256k1_ecdh (
298
279
cx : * const Context ,
299
- output : * mut SharedSecret ,
280
+ output : * mut c_uchar ,
300
281
pubkey : * const PublicKey ,
301
282
privkey : * const c_uchar ,
302
283
hashfp : EcdhHashFn ,
@@ -459,7 +440,7 @@ mod fuzz_dummy {
459
440
use self :: std:: { ptr, mem} ;
460
441
use self :: std:: boxed:: Box ;
461
442
use types:: * ;
462
- use :: { Signature , Context , NonceFn , EcdhHashFn , PublicKey , SharedSecret ,
443
+ use :: { Signature , Context , NonceFn , EcdhHashFn , PublicKey ,
463
444
SECP256K1_START_NONE , SECP256K1_START_VERIFY , SECP256K1_START_SIGN ,
464
445
SECP256K1_SER_COMPRESSED , SECP256K1_SER_UNCOMPRESSED } ;
465
446
@@ -788,7 +769,7 @@ mod fuzz_dummy {
788
769
/// Sets out to point[0..16]||scalar[0..16]
789
770
pub unsafe fn secp256k1_ecdh (
790
771
cx : * const Context ,
791
- out : * mut SharedSecret ,
772
+ out : * mut c_uchar ,
792
773
point : * const PublicKey ,
793
774
scalar : * const c_uchar ,
794
775
_hashfp : EcdhHashFn ,
@@ -801,13 +782,13 @@ mod fuzz_dummy {
801
782
ptr:: copy ( scalar, scalar_prefix[ ..] . as_mut_ptr ( ) , 16 ) ;
802
783
803
784
if ( * point) . 0 [ 0 ..16 ] > scalar_prefix[ 0 ..16 ] {
804
- ( * out ) . 0 [ 0 .. 16 ] . copy_from_slice ( & ( * point) . 0 [ 0 .. 16 ] ) ;
805
- ptr:: copy ( scalar, ( * out) . 0 [ 16 .. 32 ] . as_mut_ptr ( ) , 16 ) ;
785
+ ptr :: copy ( ( * point) . as_ptr ( ) , out , 16 ) ;
786
+ ptr:: copy ( scalar, out. offset ( 16 ) , 16 ) ;
806
787
} else {
807
- ptr:: copy ( scalar, ( * out) . 0 [ 0 .. 16 ] . as_mut_ptr ( ) , 16 ) ;
808
- ( * out ) . 0 [ 16 .. 32 ] . copy_from_slice ( & ( * point ) . 0 [ 0 .. 16 ] ) ;
788
+ ptr:: copy ( scalar, out, 16 ) ;
789
+ ptr :: copy ( ( * point ) . as_ptr ( ) , out . offset ( 16 ) , 16 ) ;
809
790
}
810
- ( * out) . 0 [ 16 ] = 0x00 ; // result should always be a valid secret key
791
+ ( * out. offset ( 16 ) ) = 0x00 ; // result should always be a valid secret key
811
792
1
812
793
}
813
794
}
0 commit comments