fn GenerateKey(priva: PrivateKey, rand: Rng) -> Result<Vec<u8>> {
    if priva.P == None || priva.Q == None || priva.G == None {
        return Err(Error::ParametersNotSet);
    }

    let mut x: BigUint;
    let mut xBytes = vec![0u8; priva.Q.bits() / 8];

    loop {
        rand.read(&mut xBytes)?;

        if x.Sign() != 0 && x.cmp(priva.Q) < 0 {
            break;
        }
    }

    priva.X = x;
    priva.Y.exp(priva.G, x, priva.P);
    return None;
}
// GenerateKey generates a public&private key pair.
GenerateKey generates a public&private key pair.
GenerateKey generates a public&private key pair .
fn GenerateKey(priva: PrivateKey, rand: Rng) -> Result<Vec<u8>> {
    if priva.P == None || priva.Q == None || priva.G == None {
        return Err(Error::ParametersNotSet);
    }
    let mut x: BigUint;
    let mut xBytes = vec![0u8; priva.Q.bits() / 8];
    loop {
        rand.read(&mut xBytes)?;
        if x.Sign() != 0 && x.cmp(priva.Q) < 0 {
            break;
        }
    }
    priva.X = x;
    priva.Y.exp(priva.G, x, priva.P);
    return None;
}
fn GenerateKey ( priva : PrivateKey , rand : Rng ) -> Result < Vec < u8 > > { if priva . P == None || priva . Q == None || priva . G == None { return Err ( Error :: ParametersNotSet ) ; } let mut x : BigUint ; let mut xBytes = vec ! [ 0u8 priva Q bits ( ) 8 ] ; loop { rand . read ( & mut xBytes ) ? ; if x . Sign ( ) != 0 && x . cmp ( priva . Q ) < 0 { break ; } } priva . X = x ; priva . Y . exp ( priva . G , x , priva . P ) ; return None ; }
GenerateKey generates a public&private key pair.
GenerateKey generates a public&private key pair .
priva
PrivateKey
rand
Rng
priva
PrivateKey
rand
Rng