-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.rs
38 lines (30 loc) · 2.3 KB
/
lib.rs
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
// 10 ATRIBUTOS
use rabe::schemes::yct14::*;
use rabe::utils::policy::pest::PolicyLanguage;
pub fn my_setupyct14 () {
let (_pk, _msk) = setup(vec!["A".to_string(), "B".to_string(), "C".to_string(), "D".to_string(), "E".to_string(),
"F".to_string(), "G".to_string(), "H".to_string(), "I".to_string(), "J".to_string()]);
}
pub fn setup_keygen_yct14 () {
let (pk, msk) = setup(vec!["A".to_string(), "B".to_string(), "C".to_string(), "D".to_string(), "E".to_string(),
"F".to_string(), "G".to_string(), "H".to_string(), "I".to_string(), "J".to_string()]);
let policy = String::from(r#"(((("A" and "B") and ("C" and "D")) and ("E" and "F")) and ("G" and "H")) and ("I" and "J")"#);
let _sk: Yct14AbeSecretKey = keygen(&pk, &msk, &policy, PolicyLanguage::HumanPolicy).unwrap();
}
pub fn setup_encrypt_yct14 () {
let (pk, _msk) = setup(vec!["A".to_string(), "B".to_string(), "C".to_string(), "D".to_string(), "E".to_string(),
"F".to_string(), "G".to_string(), "H".to_string(), "I".to_string(), "J".to_string()]);
let plaintext = String::from("hello world this is an important message,").into_bytes();
let _ct_kp: Yct14AbeCiphertext = encrypt(&pk, &vec!["A".to_string(), "B".to_string(), "C".to_string(), "D".to_string(), "E".to_string(),
"F".to_string(), "G".to_string(), "H".to_string(), "I".to_string(), "J".to_string()], &plaintext).unwrap();
}
pub fn setup_keygen_encrypt_decrypt_yct14 (){
let (pk, msk) = setup(vec!["A".to_string(), "B".to_string(), "C".to_string(), "D".to_string(), "E".to_string(),
"F".to_string(), "G".to_string(), "H".to_string(), "I".to_string(), "J".to_string()]);
let plaintext = String::from("hello world this is an important message,").into_bytes();
let policy = String::from(r#"(((("A" and "B") and ("C" and "D")) and ("E" and "F")) and ("G" and "H")) and ("I" and "J")"#);
let ct_kp: Yct14AbeCiphertext = encrypt(&pk, &vec!["A".to_string(), "B".to_string(), "C".to_string(), "D".to_string(), "E".to_string(),
"F".to_string(), "G".to_string(), "H".to_string(), "I".to_string(), "J".to_string()], &plaintext).unwrap();
let sk: Yct14AbeSecretKey = keygen(&pk, &msk, &policy, PolicyLanguage::HumanPolicy).unwrap();
assert_eq!(decrypt(&sk, &ct_kp).unwrap(), plaintext);
}