pub fn decrypt(gk: &Aw11GlobalKey, sk: &Aw11SecretKey, ct: &Aw11Ciphertext) -> Option<Vec<u8>> {
    let _str_attr = sk
        ._attr
        .iter()
        .map(|_values| {
            let (_str, _g2) = _values.clone();
            _str
        })
        .collect::<Vec<_>>();
    return if traverse_str(&_str_attr, &ct._policy) == false {
        //println!("Error: attributes in sk do not match policy in ct.");
        None
    } else {
        let _pruned = calc_pruned_str(&_str_attr, &ct._policy);
        match _pruned {
            None => {
                //println!("Error: attributes in sk do not match policy in ct.");
                None
            }
            Some(_p) => {
                let (_match, _list) = _p;
                let _coeffs = calc_coefficients_str(&ct._policy).unwrap();
                if _match {
                    let _h_g1 = blake2b_hash_g1(gk._g1, &sk._gid);
                    let mut _egg_s = Gt::one();
                    for _current in _list.iter() {
                        let _sk_attr = sk
                            ._attr
                            .iter()
                            .filter(|_attr| _attr.0 == _current.to_string())
                            .nth(0)
                            .unwrap();
                        let _ct_attr = ct
                            ._c
                            .iter()
                            .filter(|_attr| _attr.0 == _current.to_string())
                            .nth(0)
                            .unwrap();
                        let num = _ct_attr.1 * pairing(_h_g1, _ct_attr.3);
                        let dem = pairing(_sk_attr.1, _ct_attr.2);
                        let _coeff = _coeffs
                            .iter()
                            .filter(|_c| _c.0 == _current.to_string())
                            .map(|_c| _c.1)
                            .nth(0)
                            .unwrap();
                        _egg_s = _egg_s * ((num * dem.inverse()).pow(_coeff));
                    }
                    let _msg = ct._c_0 * _egg_s.inverse();
                    //println!("dec: {:?}", serde_json::to_string(&_msg).unwrap());
                    // Decrypt plaintext using derived secret from cp-abe scheme
                    decrypt_symmetric(&_msg, &ct._ct)
                } else {
                    println!("Error: attributes in sk do not match policy in ct.");
                    None
                }
            }
        }
    }
}
/// This function decrypts a 'Aw11Ciphertext' if the attributes in SK match the policy of CT. If successfull, returns the plaintext data as a Vetor of u8's.
///
/// # Arguments
///
///	* `_gk` - A Global Parameters Key (GK), generated by setup()
///	* `_sk` - A secret user key (SK), associated with a set of attributes.
///	* `_ct` - A Aw11Ciphertext
This function decrypts a 'Aw11Ciphertext' if the attributes in SK match the policy of CT. If successfull, returns the plaintext data as a Vetor of u8's.
This function decrypts a ' Aw11Ciphertext ' if the attributes in SK match the policy of CT . If successfull returns the plaintext data as a Vetor of u8 ' s .
pub fn decrypt(gk: &Aw11GlobalKey, sk: &Aw11SecretKey, ct: &Aw11Ciphertext) -> Option<Vec<u8>> {
    let _str_attr = sk
        ._attr
        .iter()
        .map(|_values| {
            let (_str, _g2) = _values.clone();
            _str
        })
        .collect::<Vec<_>>();
    return if traverse_str(&_str_attr, &ct._policy) == false {
        //println!("Error: attributes in sk do not match policy in ct.");
        None
    } else {
        let _pruned = calc_pruned_str(&_str_attr, &ct._policy);
        match _pruned {
            None => {
                //println!("Error: attributes in sk do not match policy in ct.");
                None
            }
            Some(_p) => {
                let (_match, _list) = _p;
                let _coeffs = calc_coefficients_str(&ct._policy).unwrap();
                if _match {
                    let _h_g1 = blake2b_hash_g1(gk._g1, &sk._gid);
                    let mut _egg_s = Gt::one();
                    for _current in _list.iter() {
                        let _sk_attr = sk
                            ._attr
                            .iter()
                            .filter(|_attr| _attr.0 == _current.to_string())
                            .nth(0)
                            .unwrap();
                        let _ct_attr = ct
                            ._c
                            .iter()
                            .filter(|_attr| _attr.0 == _current.to_string())
                            .nth(0)
                            .unwrap();
                        let num = _ct_attr.1 * pairing(_h_g1, _ct_attr.3);
                        let dem = pairing(_sk_attr.1, _ct_attr.2);
                        let _coeff = _coeffs
                            .iter()
                            .filter(|_c| _c.0 == _current.to_string())
                            .map(|_c| _c.1)
                            .nth(0)
                            .unwrap();
                        _egg_s = _egg_s * ((num * dem.inverse()).pow(_coeff));
                    }
                    let _msg = ct._c_0 * _egg_s.inverse();
                    //println!("dec: {:?}", serde_json::to_string(&_msg).unwrap());
                    // Decrypt plaintext using derived secret from cp-abe scheme
                    decrypt_symmetric(&_msg, &ct._ct)
                } else {
                    println!("Error: attributes in sk do not match policy in ct.");
                    None
                }
            }
        }
    }
}
pub fn decrypt ( gk : & Aw11GlobalKey , sk : & Aw11SecretKey , ct : & Aw11Ciphertext ) -> Option < Vec < u8 > > { let _str_attr = sk . _attr . iter ( ) . map ( | _values | { let ( _str , _g2 ) = _values . clone ( ) ; _str } ) . collect :: < Vec < _ > > ( ) ; return if traverse_str ( & _str_attr , & ct . _policy ) == false { //println!("Error: attributes in sk do not match policy in ct."); None } else { let _pruned = calc_pruned_str ( & _str_attr , & ct . _policy ) ; match _pruned { None => { //println!("Error: attributes in sk do not match policy in ct."); None } Some ( _p ) => { let ( _match , _list ) = _p ; let _coeffs = calc_coefficients_str ( & ct . _policy ) . unwrap ( ) ; if _match { let _h_g1 = blake2b_hash_g1 ( gk . _g1 , & sk . _gid ) ; let mut _egg_s = Gt :: one ( ) ; for _current in _list . iter ( ) { let _sk_attr = sk . _attr . iter ( ) . filter ( | _attr | _attr . 0 == _current . to_string ( ) ) . nth ( 0 ) . unwrap ( ) ; let _ct_attr = ct . _c . iter ( ) . filter ( | _attr | _attr . 0 == _current . to_string ( ) ) . nth ( 0 ) . unwrap ( ) ; let num = _ct_attr . 1 * pairing ( _h_g1 , _ct_attr . 3 ) ; let dem = pairing ( _sk_attr . 1 , _ct_attr . 2 ) ; let _coeff = _coeffs . iter ( ) . filter ( | _c | _c . 0 == _current . to_string ( ) ) . map ( | _c | _c . 1 ) . nth ( 0 ) . unwrap ( ) ; _egg_s = _egg_s * ( ( num * dem . inverse ( ) ) . pow ( _coeff ) ) ; } let _msg = ct . _c_0 * _egg_s . inverse ( ) ; //println!("dec: {:?}", serde_json::to_string(&_msg).unwrap()); // Decrypt plaintext using derived secret from cp-abe scheme decrypt_symmetric ( & _msg , & ct . _ct ) } else { println ! ( " " ) ; None } } } } }
This function decrypts a 'Aw11Ciphertext' if the attributes in SK match the policy of CT.
This function decrypts a ' Aw11Ciphertext ' if the attributes in SK match the policy of CT .
gk
&Aw11GlobalKey
sk
&Aw11SecretKey
ct
&Aw11Ciphertext
gk
&Aw11GlobalKey
sk
&Aw11SecretKey
ct
&Aw11Ciphertext