pub fn dh_init_secp256k1(n: usize) -> Result<(Vec<Secp256k1Scalar>, Vec<Secp256k1Point>), ()> {
    // don't allow creating too many values at once.
    if n > 100 {
        return Err(());
    }
    let base: Secp256k1Point = ECPoint::generator();
    let mut dh_secrets: Vec<Secp256k1Scalar> = Vec::new();
    let mut dh_publics: Vec<Secp256k1Point> = Vec::new();
    for _ in 0..n {
        let dh_secret = match Secp256k1Scalar::new_random() {
            Ok(v) => v,
            Err(_) => return Err(()),
        };
        let dh_public = match &base * &dh_secret {
            Ok(v) => v,
            Err(_) => return Err(()),
        };
        dh_secrets.push(dh_secret);
        dh_publics.push(dh_public);
    }
    Ok((dh_secrets, dh_publics))
}
/// Diffie-Hellman: create a set of secret values and a set of public values (using curve secp256k1)
Diffie-Hellman: create a set of secret values and a set of public values (using curve secp256k1)
Diffie - Hellman : create a set of secret values and a set of public values ( using curve secp256k1 )
pub fn dh_init_secp256k1(n: usize) -> Result<(Vec<Secp256k1Scalar>, Vec<Secp256k1Point>), ()> {
    // don't allow creating too many values at once.
    if n > 100 {
        return Err(());
    }
    let base: Secp256k1Point = ECPoint::generator();
    let mut dh_secrets: Vec<Secp256k1Scalar> = Vec::new();
    let mut dh_publics: Vec<Secp256k1Point> = Vec::new();
    for _ in 0..n {
        let dh_secret = match Secp256k1Scalar::new_random() {
            Ok(v) => v,
            Err(_) => return Err(()),
        };
        let dh_public = match &base * &dh_secret {
            Ok(v) => v,
            Err(_) => return Err(()),
        };
        dh_secrets.push(dh_secret);
        dh_publics.push(dh_public);
    }
    Ok((dh_secrets, dh_publics))
}
pub fn dh_init_secp256k1 ( n : usize ) -> Result < ( Vec < Secp256k1Scalar > , Vec < Secp256k1Point > ) , ( ) > { // don't allow creating too many values at once. if n > 100 { return Err ( ( ) ) ; } let base : Secp256k1Point = ECPoint :: generator ( ) ; let mut dh_secrets : Vec < Secp256k1Scalar > = Vec :: new ( ) ; let mut dh_publics : Vec < Secp256k1Point > = Vec :: new ( ) ; for _ in 0 .. n { let dh_secret = match Secp256k1Scalar :: new_random ( ) { Ok ( v ) => v , Err ( _ ) => return Err ( ( ) ) , } ; let dh_public = match & base * & dh_secret { Ok ( v ) => v , Err ( _ ) => return Err ( ( ) ) , } ; dh_secrets . push ( dh_secret ) ; dh_publics . push ( dh_public ) ; } Ok ( ( dh_secrets , dh_publics ) ) }
Diffie-Hellman: create a set of secret values and a set of public values (using curve secp256k1)
Diffie - Hellman : create a set of secret values and a set of public values ( using curve secp256k1 )
n
usize