/// Generates a (public key, secret key) pair for of forward-secure
/// public-key encryption scheme.
///
/// # Arguments:
/// * `associated_data`: public information for the Proof of Possession of the
///   key.
/// * `sys`: system parameters for the FS Encryption scheme.
/// * `rng`: seeded pseudo random number generator.
Generates a (public key, secret key) pair for of forward-secure
public-key encryption scheme.
Generates a ( public key secret key ) pair for of forward - secure public - key encryption scheme .
pub fn kgen(
    associated_data: &[u8],
    sys: &SysParam,
    rng: &mut impl RAND,
) -> (PublicKeyWithPop, SecretKey) {
    let g1 = ECP::generator();
    let g2 = ECP2::generator();
    let spec_p = BIG::new_ints(&rom::CURVE_ORDER);
    // x <- getRandomZp
    // rho <- getRandomZp
    // let y = g1^x
    // let pk = (y, pi_dlog)
    // let dk = (g1^rho, g2^x * f0^rho, f1^rho, ..., f_lambda^rho, h^rho)
    // return (pk, dk)
    let spec_x = BIG::randomnum(&spec_p, rng);
    let rho = BIG::randomnum(&spec_p, rng);
    let a = g1.mul(&rho);
    let mut b = g2.mul(&spec_x);
    b.add(&sys.f0.mul(&rho));
    let mut d_t = LinkedList::new();
    for f in sys.f.iter() {
        d_t.push_back(f.mul(&rho));
    }
    let mut d_h = Vec::new();
    for f in sys.f_h.iter() {
        d_h.push(f.mul(&rho));
    }
    let e = sys.h.mul(&rho);
    let bte_root = BTENode {
        tau: Vec::new(),
        a,
        b,
        d_t,
        d_h,
        e,
    };
    let sk = SecretKey::new(bte_root);
    let y = g1.mul(&spec_x);
    let pop_instance = EncryptionKeyInstance {
        g1_gen: ECP::generator(),
        public_key: y.clone(),
        associated_data: associated_data.to_vec(),
    };
    let pop =
        prove_pop(&pop_instance, &spec_x, rng).expect("Implementation bug: Pop generation failed");
    (
        PublicKeyWithPop {
            key_value: y,
            proof_data: pop,
        },
        sk,
    )
}
pub fn kgen ( associated_data : & [ u8 ] , sys : & SysParam , rng : & mut impl RAND , ) -> ( PublicKeyWithPop , SecretKey ) { let g1 = ECP :: generator ( ) ; let g2 = ECP2 :: generator ( ) ; let spec_p = BIG :: new_ints ( & rom :: CURVE_ORDER ) ; // x <- getRandomZp // rho <- getRandomZp // let y = g1^x // let pk = (y, pi_dlog) // let dk = (g1^rho, g2^x * f0^rho, f1^rho, ..., f_lambda^rho, h^rho) // return (pk, dk) let spec_x = BIG :: randomnum ( & spec_p , rng ) ; let rho = BIG :: randomnum ( & spec_p , rng ) ; let a = g1 . mul ( & rho ) ; let mut b = g2 . mul ( & spec_x ) ; b . add ( & sys . f0 . mul ( & rho ) ) ; let mut d_t = LinkedList :: new ( ) ; for f in sys . f . iter ( ) { d_t . push_back ( f . mul ( & rho ) ) ; } let mut d_h = Vec :: new ( ) ; for f in sys . f_h . iter ( ) { d_h . push ( f . mul ( & rho ) ) ; } let e = sys . h . mul ( & rho ) ; let bte_root = BTENode { tau : Vec :: new ( ) , a , b , d_t , d_h , e , } ; let sk = SecretKey :: new ( bte_root ) ; let y = g1 . mul ( & spec_x ) ; let pop_instance = EncryptionKeyInstance { g1_gen : ECP :: generator ( ) , public_key : y . clone ( ) , associated_data : associated_data . to_vec ( ) , } ; let pop = prove_pop ( & pop_instance , & spec_x , rng ) . expect ( " " ) ; ( PublicKeyWithPop { key_value : y , proof_data : pop , } , sk , ) }
Generates a (public key, secret key) pair for of forward-secure
public-key encryption scheme.
Generates a ( public key secret key ) pair for of forward - secure public - key encryption scheme .
associated_data
&[u8]
sys
&SysParam
rng
&mut impl RAND
arguments:
`associated_data`: public information for the Proof of Possession of the
key.
`sys`: system parameters for the FS Encryption scheme.
`rng`: seeded pseudo random number generator.
` associated_data ` : public information for the Proof of Possession of the key . ` sys ` : system parameters for the FS Encryption scheme . ` rng ` : seeded pseudo random number generator .