|
|
|
@ -24,6 +24,30 @@ mod tests {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
mod crypto { |
|
|
|
|
use crate::crypto::{PublicKey, Keys, verify_sign}; |
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
|
fn creation() { |
|
|
|
|
let key_pair = Keys::gen(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
|
fn signing() { |
|
|
|
|
let key_pair = Keys::gen(); |
|
|
|
|
key_pair.sign(&[1u8; 129].to_vec()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
|
fn verification() { |
|
|
|
|
let key_pair = Keys::gen(); |
|
|
|
|
let sign = key_pair.sign(&[1u8; 129].to_vec()); |
|
|
|
|
assert!(key_pair.get_public().verify_sign(&[1u8; 129].to_vec(), &sign)); |
|
|
|
|
assert!(!key_pair.get_public().verify_sign(&[0u8; 129].to_vec(), &sign)); |
|
|
|
|
assert!(!key_pair.get_public().verify_sign(&[1u8; 129].to_vec(), &[0u8; 64].to_vec())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
mod message { |
|
|
|
|
use crate::message::{MsgType, Message}; |
|
|
|
|
use crate::crypto::Keys; |
|
|
|
|