pub fn dnf<K: PublicAttributeKey>(
    _dnfp: &mut DnfPolicy,
    _pks: &Vec<K>,
    _p: &serde_json::Value,
    _i: usize,
) -> bool {
    if *_p == serde_json::Value::Null {
        println!("Error passed null!");
        return false;
    }
    let mut ret = true;
    // inner node
    if _p["OR"].is_array() {
        let len = _p["OR"].as_array().unwrap().len();
        for i in 0usize..len {
            ret = ret && dnf(_dnfp, _pks, &_p["OR"][i], i + _i)
        }
        return ret;
    } else if _p["AND"].is_array() {
        let len = _p["AND"].as_array().unwrap().len();
        for i in 0usize..len {
            ret = ret && dnf(_dnfp, _pks, &_p["AND"][i], _i)
        }
        return ret;
    }
    //Leaf
    else if _p["ATT"] != serde_json::Value::Null {
        match _p["ATT"].as_str() {
            Some(_s) => {
                for pak in _pks.iter() {
                    if pak._str() == _s {
                        if _dnfp._terms.len() > _i {
                            _dnfp._terms[_i].0.push(pak._str().to_string());
                            _dnfp._terms[_i] = (
                                _dnfp._terms[_i].0.clone(),
                                _dnfp._terms[_i].1 * pak._gt1(),
                                _dnfp._terms[_i].2 * pak._gt2(),
                                _dnfp._terms[_i].3 + pak._g1(),
                                _dnfp._terms[_i].4 + pak._g2(),
                            );
                        } else {
                            _dnfp._terms.push((
                                vec![pak._str().to_string()],
                                pak._gt1(),
                                pak._gt2(),
                                pak._g1(),
                                pak._g2(),
                            ));
                        }
                    }
                }
            }
            None => {
                println!("ERROR attribute value");
                return false;
            }
        }
        return true;
    } else {
        println!("Policy invalid. No AND or OR found");
        return false;
    }
}
// this calcluates the sum's of all AND terms in a Bdabe DNF policy
this calcluates the sum's of all AND terms in a Bdabe DNF policy
this calcluates the sum ' s of all AND terms in a Bdabe DNF policy
pub fn dnf<K: PublicAttributeKey>(
    _dnfp: &mut DnfPolicy,
    _pks: &Vec<K>,
    _p: &serde_json::Value,
    _i: usize,
) -> bool {
    if *_p == serde_json::Value::Null {
        println!("Error passed null!");
        return false;
    }
    let mut ret = true;
    // inner node
    if _p["OR"].is_array() {
        let len = _p["OR"].as_array().unwrap().len();
        for i in 0usize..len {
            ret = ret && dnf(_dnfp, _pks, &_p["OR"][i], i + _i)
        }
        return ret;
    } else if _p["AND"].is_array() {
        let len = _p["AND"].as_array().unwrap().len();
        for i in 0usize..len {
            ret = ret && dnf(_dnfp, _pks, &_p["AND"][i], _i)
        }
        return ret;
    }
    //Leaf
    else if _p["ATT"] != serde_json::Value::Null {
        match _p["ATT"].as_str() {
            Some(_s) => {
                for pak in _pks.iter() {
                    if pak._str() == _s {
                        if _dnfp._terms.len() > _i {
                            _dnfp._terms[_i].0.push(pak._str().to_string());
                            _dnfp._terms[_i] = (
                                _dnfp._terms[_i].0.clone(),
                                _dnfp._terms[_i].1 * pak._gt1(),
                                _dnfp._terms[_i].2 * pak._gt2(),
                                _dnfp._terms[_i].3 + pak._g1(),
                                _dnfp._terms[_i].4 + pak._g2(),
                            );
                        } else {
                            _dnfp._terms.push((
                                vec![pak._str().to_string()],
                                pak._gt1(),
                                pak._gt2(),
                                pak._g1(),
                                pak._g2(),
                            ));
                        }
                    }
                }
            }
            None => {
                println!("ERROR attribute value");
                return false;
            }
        }
        return true;
    } else {
        println!("Policy invalid. No AND or OR found");
        return false;
    }
}
pub fn dnf < K : PublicAttributeKey > ( _dnfp : & mut DnfPolicy , _pks : & Vec < K > , _p : & serde_json :: Value , _i : usize , ) -> bool { if * _p == serde_json :: Value :: Null { println ! ( " " ) ; return false ; } let mut ret = true ; // inner node if _p [ " " ] . is_array ( ) { let len = _p [ " " ] . as_array ( ) . unwrap ( ) . len ( ) ; for i in 0usize .. len { ret = ret && dnf ( _dnfp , _pks , & _p [ " " ] [ i ] , i + _i ) } return ret ; } else if _p [ " " ] . is_array ( ) { let len = _p [ " " ] . as_array ( ) . unwrap ( ) . len ( ) ; for i in 0usize .. len { ret = ret && dnf ( _dnfp , _pks , & _p [ " " ] [ i ] , _i ) } return ret ; } //Leaf else if _p [ " " ] != serde_json :: Value :: Null { match _p [ " " ] . as_str ( ) { Some ( _s ) => { for pak in _pks . iter ( ) { if pak . _str ( ) == _s { if _dnfp . _terms . len ( ) > _i { _dnfp . _terms [ _i ] . 0 . push ( pak . _str ( ) . to_string ( ) ) ; _dnfp . _terms [ _i ] = ( _dnfp . _terms [ _i ] . 0 . clone ( ) , _dnfp . _terms [ _i ] . 1 * pak . _gt1 ( ) , _dnfp . _terms [ _i ] . 2 * pak . _gt2 ( ) , _dnfp . _terms [ _i ] . 3 + pak . _g1 ( ) , _dnfp . _terms [ _i ] . 4 + pak . _g2 ( ) , ) ; } else { _dnfp . _terms . push ( ( vec ! [ pak str ( ) to_string ( ) ] , pak . _gt1 ( ) , pak . _gt2 ( ) , pak . _g1 ( ) , pak . _g2 ( ) , ) ) ; } } } } None => { println ! ( " " ) ; return false ; } } return true ; } else { println ! ( " " ) ; return false ; } }
this calcluates the sum's of all AND terms in a Bdabe DNF policy
this calcluates the sum ' s of all AND terms in a Bdabe DNF policy
_dnfp
&mut DnfPolicy
_pks
&Vec<K>
_p
&serde_json::Value
_i
usize
_dnfp
&mut DnfPolicy
_pks
&Vec<K>
_p
&serde_json::Value
_i
usize