Touch recovery module in no_std_test

This commit is contained in:
Jules Comte 2021-05-20 07:18:42 -06:00
parent a66f581b36
commit c925644b74
2 changed files with 9 additions and 2 deletions

View File

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Elichai Turkel <elichai.turkel@gmail.com>"]
[dependencies]
secp256k1 = { path = "../", default-features = false, features = ["serde", "rand"] }
secp256k1 = { path = "../", default-features = false, features = ["serde", "rand", "recovery"] }
libc = { version = "0.2", default-features = false }
serde_cbor = { version = "0.10", default-features = false } # A random serializer that supports no-std.

View File

@ -15,7 +15,7 @@
//! # secp256k1 no-std test.
//! This binary is a short smallest rust code to produce a working binary *without libstd*.
//! This gives us 2 things:
//! 1. Test that the parts of the code that should work in a no-std enviroment actually work.
//! 1. Test that the parts of the code that should work in a no-std enviroment actually work. Note that this is not a comprehensive list.
//! 2. Test that we don't accidentally import libstd into `secp256k1`.
//!
//! The first is tested using the following command `cargo run --release | grep -q "Verified Successfully"`.
@ -96,6 +96,13 @@ fn start(_argc: isize, _argv: *const *const u8) -> isize {
let sig = secp.sign(&message, &secret_key);
assert!(secp.verify(&message, &sig, &public_key).is_ok());
let rec_sig = secp.sign_recoverable(&message, &secret_key);
assert!(secp.verify(&message, &rec_sig.to_standard(), &public_key).is_ok());
assert_eq!(public_key, secp.recover(&message, &rec_sig).unwrap());
let (rec_id, data) = rec_sig.serialize_compact();
let new_rec_sig = recovery::RecoverableSignature::from_compact(&data, rec_id).unwrap();
assert_eq!(rec_sig, new_rec_sig);
let mut cbor_ser = [0u8; 100];
let writer = SliceWrite::new(&mut cbor_ser[..]);
let mut ser = Serializer::new(writer);