Skip to content

Commit 92c42ca

Browse files
committed
Add ECDH to the no-std tests
1 parent 5619f2a commit 92c42ca

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

no_std_test/src/main.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ use core::panic::PanicInfo;
5555
use secp256k1::rand::{self, RngCore};
5656
use secp256k1::serde::Serialize;
5757
use secp256k1::*;
58+
use secp256k1::ecdh::SharedSecret;
5859

5960
use serde_cbor::de;
6061
use serde_cbor::ser::SliceWrite;
@@ -102,6 +103,16 @@ fn start(_argc: isize, _argv: *const *const u8) -> isize {
102103
let new_sig: Signature = de::from_mut_slice(&mut cbor_ser[..size]).unwrap();
103104
assert_eq!(sig, new_sig);
104105

106+
let _ = SharedSecret::new(&public_key, &secret_key);
107+
let mut x_arr = [0u8; 32];
108+
let y_arr = unsafe { SharedSecret::new_with_hash_no_panic(&public_key, &secret_key, |x,y| {
109+
x_arr = x;
110+
y.into()
111+
})}.unwrap();
112+
assert_ne!(x_arr, [0u8; 32]);
113+
assert_ne!(&y_arr[..], &[0u8; 32][..]);
114+
115+
105116
unsafe { libc::printf("Verified Successfully!\n\0".as_ptr() as _) };
106117
0
107118
}

0 commit comments

Comments
 (0)