Add ECDH to the no-std tests

This commit is contained in:
Elichai Turkel 2019-11-28 00:42:15 +02:00
parent 5619f2a5df
commit 92c42ca9e6
No known key found for this signature in database
GPG Key ID: 9383CDE9E8E66A7F
1 changed files with 11 additions and 0 deletions

View File

@ -55,6 +55,7 @@ use core::panic::PanicInfo;
use secp256k1::rand::{self, RngCore};
use secp256k1::serde::Serialize;
use secp256k1::*;
use secp256k1::ecdh::SharedSecret;
use serde_cbor::de;
use serde_cbor::ser::SliceWrite;
@ -102,6 +103,16 @@ fn start(_argc: isize, _argv: *const *const u8) -> isize {
let new_sig: Signature = de::from_mut_slice(&mut cbor_ser[..size]).unwrap();
assert_eq!(sig, new_sig);
let _ = SharedSecret::new(&public_key, &secret_key);
let mut x_arr = [0u8; 32];
let y_arr = unsafe { SharedSecret::new_with_hash_no_panic(&public_key, &secret_key, |x,y| {
x_arr = x;
y.into()
})}.unwrap();
assert_ne!(x_arr, [0u8; 32]);
assert_ne!(&y_arr[..], &[0u8; 32][..]);
unsafe { libc::printf("Verified Successfully!\n\0".as_ptr() as _) };
0
}