pub fn kp_decrypt(sk: &Ac17KpSecretKey, ct: &Ac17KpCiphertext) -> Option<Vec<u8>> {
    return if traverse_str(&ct._attr, &sk._policy) == false {
        println!("Error: attributes in ct do not match policy in sk.");
        None
    } else {
        match calc_pruned_str(&ct._attr, &sk._policy) {
            None => {
                println!("Error: attributes in sk do not match policy in ct.");
                None
            }
            Some(_p) => {
                let (_match, _list) = _p;
                if _match {
                    let mut _prod1_gt = Gt::one();
                    let mut _prod2_gt = Gt::one();
                    for _i in 0usize..(ASSUMPTION_SIZE + 1) {
                        let mut _prod_h = G1::zero();
                        let mut _prod_g = G1::zero();
                        for _current in _list.iter() {
                            for _attr in ct._ct._c.iter() {
                                if _attr.0 == _current.to_string() {
                                    _prod_g = _prod_g + _attr.1[_i];
                                }
                            }
                            for _attr in sk._sk._k.iter() {
                                if _attr.0 == _current.to_string() {
                                    _prod_h = _prod_h + _attr.1[_i];
                                }
                            }
                        }
                        // for _j in 0usize..ct._ct._c.len() {
                        //     _prod_h = _prod_h + sk._sk._k[_j].1[_i];
                        //     _prod_g = _prod_g + ct._ct._c[_j].1[_i];
                        // }
                        _prod1_gt = _prod1_gt * pairing(_prod_h, ct._ct._c_0[_i]);
                        _prod2_gt = _prod2_gt * pairing(_prod_g, sk._sk._k_0[_i]);
                    }
                    let _msg = ct._ct._c_p * (_prod2_gt * _prod1_gt.inverse());
                    // Decrypt plaintext using derived secret from cp-abe scheme
                    decrypt_symmetric(&_msg, &ct._ct._ct)
                } else {
                    println!("Error: attributes in sk do not match policy in ct.");
                    None
                }
            }
        }
    }
}
/// The decrypt algorithm of AC17KP. Reconstructs the original plaintext data as Vec<u8>, given a Ac17KpCiphertext with a matching Ac17KpSecretKey.
///
/// # Arguments
///
///	* `sk` - A Secret Key (SK), generated by the function kp_keygen()
///	* `ct` - An AC17KP Ciphertext
///
The decrypt algorithm of AC17KP. Reconstructs the original plaintext data as Vec, given a Ac17KpCiphertext with a matching Ac17KpSecretKey.
The decrypt algorithm of AC17KP . Reconstructs the original plaintext data as Vec given a Ac17KpCiphertext with a matching Ac17KpSecretKey .
pub fn kp_decrypt(sk: &Ac17KpSecretKey, ct: &Ac17KpCiphertext) -> Option<Vec<u8>> {
    return if traverse_str(&ct._attr, &sk._policy) == false {
        println!("Error: attributes in ct do not match policy in sk.");
        None
    } else {
        match calc_pruned_str(&ct._attr, &sk._policy) {
            None => {
                println!("Error: attributes in sk do not match policy in ct.");
                None
            }
            Some(_p) => {
                let (_match, _list) = _p;
                if _match {
                    let mut _prod1_gt = Gt::one();
                    let mut _prod2_gt = Gt::one();
                    for _i in 0usize..(ASSUMPTION_SIZE + 1) {
                        let mut _prod_h = G1::zero();
                        let mut _prod_g = G1::zero();
                        for _current in _list.iter() {
                            for _attr in ct._ct._c.iter() {
                                if _attr.0 == _current.to_string() {
                                    _prod_g = _prod_g + _attr.1[_i];
                                }
                            }
                            for _attr in sk._sk._k.iter() {
                                if _attr.0 == _current.to_string() {
                                    _prod_h = _prod_h + _attr.1[_i];
                                }
                            }
                        }
                        // for _j in 0usize..ct._ct._c.len() {
                        //     _prod_h = _prod_h + sk._sk._k[_j].1[_i];
                        //     _prod_g = _prod_g + ct._ct._c[_j].1[_i];
                        // }
                        _prod1_gt = _prod1_gt * pairing(_prod_h, ct._ct._c_0[_i]);
                        _prod2_gt = _prod2_gt * pairing(_prod_g, sk._sk._k_0[_i]);
                    }
                    let _msg = ct._ct._c_p * (_prod2_gt * _prod1_gt.inverse());
                    // Decrypt plaintext using derived secret from cp-abe scheme
                    decrypt_symmetric(&_msg, &ct._ct._ct)
                } else {
                    println!("Error: attributes in sk do not match policy in ct.");
                    None
                }
            }
        }
    }
}
pub fn kp_decrypt ( sk : & Ac17KpSecretKey , ct : & Ac17KpCiphertext ) -> Option < Vec < u8 > > { return if traverse_str ( & ct . _attr , & sk . _policy ) == false { println ! ( " " ) ; None } else { match calc_pruned_str ( & ct . _attr , & sk . _policy ) { None => { println ! ( " " ) ; None } Some ( _p ) => { let ( _match , _list ) = _p ; if _match { let mut _prod1_gt = Gt :: one ( ) ; let mut _prod2_gt = Gt :: one ( ) ; for _i in 0usize .. ( ASSUMPTION_SIZE + 1 ) { let mut _prod_h = G1 :: zero ( ) ; let mut _prod_g = G1 :: zero ( ) ; for _current in _list . iter ( ) { for _attr in ct . _ct . _c . iter ( ) { if _attr . 0 == _current . to_string ( ) { _prod_g = _prod_g + _attr . 1 [ _i ] ; } } for _attr in sk . _sk . _k . iter ( ) { if _attr . 0 == _current . to_string ( ) { _prod_h = _prod_h + _attr . 1 [ _i ] ; } } } // for _j in 0usize..ct._ct._c.len() { //     _prod_h = _prod_h + sk._sk._k[_j].1[_i]; //     _prod_g = _prod_g + ct._ct._c[_j].1[_i]; // } _prod1_gt = _prod1_gt * pairing ( _prod_h , ct . _ct . _c_0 [ _i ] ) ; _prod2_gt = _prod2_gt * pairing ( _prod_g , sk . _sk . _k_0 [ _i ] ) ; } let _msg = ct . _ct . _c_p * ( _prod2_gt * _prod1_gt . inverse ( ) ) ; // Decrypt plaintext using derived secret from cp-abe scheme decrypt_symmetric ( & _msg , & ct . _ct . _ct ) } else { println ! ( " " ) ; None } } } } }
The decrypt algorithm of AC17KP.
The decrypt algorithm of AC17KP .
sk
&Ac17KpSecretKey
ct
&Ac17KpCiphertext
sk
&Ac17KpSecretKey
ct
&Ac17KpCiphertext