diff options
Diffstat (limited to 'src/sign.rs')
-rw-r--r-- | src/sign.rs | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/src/sign.rs b/src/sign.rs index c81ad38..d7ef156 100644 --- a/src/sign.rs +++ b/src/sign.rs @@ -20,6 +20,7 @@ extern crate ring; extern crate untrusted; +extern crate hex; use self::ring::signature; use self::ring::signature::Ed25519KeyPair; @@ -92,17 +93,14 @@ impl Signer { #[cfg(test)] mod test { - use hex::*; use super::*; #[test] fn verify_ed25519_sig_on_empty_message() { - let pubkey = "d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a" - .from_hex() + let pubkey = hex::decode("d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a") .unwrap(); - let signature = "e5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e065224901555fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b" - .from_hex() + let signature = hex::decode("e5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e065224901555fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b") .unwrap(); let v = Verifier::new(&pubkey); @@ -112,14 +110,12 @@ mod test { #[test] fn verify_ed25519_sig() { - let pubkey = "c0dac102c4533186e25dc43128472353eaabdb878b152aeb8e001f92d90233a7" - .from_hex() + let pubkey = hex::decode("c0dac102c4533186e25dc43128472353eaabdb878b152aeb8e001f92d90233a7") .unwrap(); - let message = "5f4c8989".from_hex().unwrap(); + let message = hex::decode("5f4c8989").unwrap(); - let signature = "124f6fc6b0d100842769e71bd530664d888df8507df6c56dedfdb509aeb93416e26b918d38aa06305df3095697c18b2aa832eaa52edc0ae49fbae5a85e150c07" - .from_hex() + let signature = hex::decode("124f6fc6b0d100842769e71bd530664d888df8507df6c56dedfdb509aeb93416e26b918d38aa06305df3095697c18b2aa832eaa52edc0ae49fbae5a85e150c07") .unwrap(); let mut v = Verifier::new(&pubkey); @@ -130,12 +126,10 @@ mod test { #[test] fn sign_ed25519_empty_message() { - let seed = "9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60" - .from_hex() + let seed = hex::decode("9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60") .unwrap(); - let expected_sig = "e5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e065224901555fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b" - .from_hex() + let expected_sig = hex::decode("e5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e065224901555fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b") .unwrap(); let mut s = Signer::new(&seed); @@ -145,14 +139,12 @@ mod test { #[test] fn sign_ed25519_message() { - let seed = "0d4a05b07352a5436e180356da0ae6efa0345ff7fb1572575772e8005ed978e9" - .from_hex() + let seed = hex::decode("0d4a05b07352a5436e180356da0ae6efa0345ff7fb1572575772e8005ed978e9") .unwrap(); - let message = "cbc77b".from_hex().unwrap(); + let message = hex::decode("cbc77b").unwrap(); - let expected_sig = "d9868d52c2bebce5f3fa5a79891970f309cb6591e3e1702a70276fa97c24b3a8e58606c38c9758529da50ee31b8219cba45271c689afa60b0ea26c99db19b00c" - .from_hex() + let expected_sig = hex::decode("d9868d52c2bebce5f3fa5a79891970f309cb6591e3e1702a70276fa97c24b3a8e58606c38c9758529da50ee31b8219cba45271c689afa60b0ea26c99db19b00c") .unwrap(); let mut s = Signer::new(&seed); @@ -163,8 +155,7 @@ mod test { #[test] fn sign_verify_round_trip() { - let seed = "334a05b07352a5436e180356da0ae6efa0345ff7fb1572575772e8005ed978e9" - .from_hex() + let seed = hex::decode("334a05b07352a5436e180356da0ae6efa0345ff7fb1572575772e8005ed978e9") .unwrap(); let message = "Hello world".as_bytes(); |