Skip to content

Commit cf8921a

Browse files
authored
Merge pull request #302 from jules23/recovery-no-std-test
Touch recovery module in no_std_test
2 parents a66f581 + c925644 commit cf8921a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

no_std_test/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
authors = ["Elichai Turkel <elichai.turkel@gmail.com>"]
55

66
[dependencies]
7-
secp256k1 = { path = "../", default-features = false, features = ["serde", "rand"] }
7+
secp256k1 = { path = "../", default-features = false, features = ["serde", "rand", "recovery"] }
88
libc = { version = "0.2", default-features = false }
99
serde_cbor = { version = "0.10", default-features = false } # A random serializer that supports no-std.
1010

no_std_test/src/main.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//! # secp256k1 no-std test.
1616
//! This binary is a short smallest rust code to produce a working binary *without libstd*.
1717
//! This gives us 2 things:
18-
//! 1. Test that the parts of the code that should work in a no-std enviroment actually work.
18+
//! 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.
1919
//! 2. Test that we don't accidentally import libstd into `secp256k1`.
2020
//!
2121
//! 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 {
9696
let sig = secp.sign(&message, &secret_key);
9797
assert!(secp.verify(&message, &sig, &public_key).is_ok());
9898

99+
let rec_sig = secp.sign_recoverable(&message, &secret_key);
100+
assert!(secp.verify(&message, &rec_sig.to_standard(), &public_key).is_ok());
101+
assert_eq!(public_key, secp.recover(&message, &rec_sig).unwrap());
102+
let (rec_id, data) = rec_sig.serialize_compact();
103+
let new_rec_sig = recovery::RecoverableSignature::from_compact(&data, rec_id).unwrap();
104+
assert_eq!(rec_sig, new_rec_sig);
105+
99106
let mut cbor_ser = [0u8; 100];
100107
let writer = SliceWrite::new(&mut cbor_ser[..]);
101108
let mut ser = Serializer::new(writer);

0 commit comments

Comments
 (0)