Merge pull request #302 from jules23/recovery-no-std-test
Touch recovery module in no_std_test
This commit is contained in:
commit
cf8921a338
|
@ -4,7 +4,7 @@ version = "0.1.0"
|
||||||
authors = ["Elichai Turkel <elichai.turkel@gmail.com>"]
|
authors = ["Elichai Turkel <elichai.turkel@gmail.com>"]
|
||||||
|
|
||||||
[dependencies]
|
[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 }
|
libc = { version = "0.2", default-features = false }
|
||||||
serde_cbor = { version = "0.10", default-features = false } # A random serializer that supports no-std.
|
serde_cbor = { version = "0.10", default-features = false } # A random serializer that supports no-std.
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
//! # secp256k1 no-std test.
|
//! # secp256k1 no-std test.
|
||||||
//! This binary is a short smallest rust code to produce a working binary *without libstd*.
|
//! This binary is a short smallest rust code to produce a working binary *without libstd*.
|
||||||
//! This gives us 2 things:
|
//! 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`.
|
//! 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"`.
|
//! 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);
|
let sig = secp.sign(&message, &secret_key);
|
||||||
assert!(secp.verify(&message, &sig, &public_key).is_ok());
|
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 mut cbor_ser = [0u8; 100];
|
||||||
let writer = SliceWrite::new(&mut cbor_ser[..]);
|
let writer = SliceWrite::new(&mut cbor_ser[..]);
|
||||||
let mut ser = Serializer::new(writer);
|
let mut ser = Serializer::new(writer);
|
||||||
|
|
Loading…
Reference in New Issue