1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#[allow(non_camel_case_types)]
#[deny(unsafe_code)]
pub mod constants;
pub mod sel_errors;
pub mod crypto;
pub mod certificate;
pub mod random;
#[cfg(test)]
mod tests {
use super::crypto::{Falcon512Keypair, Keypairs, Signatures, SphincsKeypair};
#[test]
fn it_works() {
let keypair = Falcon512Keypair::new();
let yaml = keypair.serialize();
let x = Falcon512Keypair::deserialize(&yaml);
println!("{}",x.public_key);
println!();
let sig = keypair.sign("Hello");
sig.verify();
}
#[test]
fn sphincs_plus(){
let keypair = SphincsKeypair::new();
let signature = keypair.sign("FFDE");
signature.verify();
}
#[test]
fn get_keypair_size(){
let keypair = SphincsKeypair::new();
let sig = keypair.sign("DJNASJNDASNJNJDSJNNJASDNJNJADSJNIDJNIJINEDJNNJIDENJDE");
let is_verified = sig.verify();
let size_of_pk = keypair.public_key_as_bytes().len();
let size_of_sk = keypair.secret_key_as_bytes().len();
let size_of_signature = base64::decode(&sig.signature).unwrap().len();
println!("Algorithm: {}",keypair.algorithm);
println!("Size of PK: {}",size_of_pk);
println!("Size of SK: {}",size_of_sk);
println!("Size of Signature: {}",size_of_signature);
println!("Signature is Verified: {}",is_verified);
}
}