@@ -72,7 +72,7 @@ pub type EcdhHashFn = unsafe extern "C" fn(
7272 x : * const c_uchar ,
7373 y : * const c_uchar ,
7474 data : * mut c_void ,
75- ) ;
75+ ) -> c_int ;
7676
7777/// A Secp256k1 context, containing various precomputed values and such
7878/// needed to do elliptic curve computations. If you create one of these
@@ -134,25 +134,6 @@ impl Default for Signature {
134134 }
135135}
136136
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- }
156137
157138#[ cfg( not( feature = "fuzztarget" ) ) ]
158139extern "C" {
@@ -296,7 +277,7 @@ extern "C" {
296277 #[ cfg_attr( not( feature = "external-symbols" ) , link_name = "rustsecp256k1_v0_1_0_ecdh" ) ]
297278 pub fn secp256k1_ecdh (
298279 cx : * const Context ,
299- output : * mut SharedSecret ,
280+ output : * mut c_uchar ,
300281 pubkey : * const PublicKey ,
301282 privkey : * const c_uchar ,
302283 hashfp : EcdhHashFn ,
@@ -459,7 +440,7 @@ mod fuzz_dummy {
459440 use self :: std:: { ptr, mem} ;
460441 use self :: std:: boxed:: Box ;
461442 use types:: * ;
462- use :: { Signature , Context , NonceFn , EcdhHashFn , PublicKey , SharedSecret ,
443+ use :: { Signature , Context , NonceFn , EcdhHashFn , PublicKey ,
463444 SECP256K1_START_NONE , SECP256K1_START_VERIFY , SECP256K1_START_SIGN ,
464445 SECP256K1_SER_COMPRESSED , SECP256K1_SER_UNCOMPRESSED } ;
465446
@@ -788,7 +769,7 @@ mod fuzz_dummy {
788769 /// Sets out to point[0..16]||scalar[0..16]
789770 pub unsafe fn secp256k1_ecdh (
790771 cx : * const Context ,
791- out : * mut SharedSecret ,
772+ out : * mut c_uchar ,
792773 point : * const PublicKey ,
793774 scalar : * const c_uchar ,
794775 _hashfp : EcdhHashFn ,
@@ -801,13 +782,13 @@ mod fuzz_dummy {
801782 ptr:: copy ( scalar, scalar_prefix[ ..] . as_mut_ptr ( ) , 16 ) ;
802783
803784 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 ) ;
806787 } 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 ) ;
809790 }
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
811792 1
812793 }
813794}
0 commit comments