pub fn generate_crs<R>(rng: &mut R) -> CRS<E>
    where
        R: Rng + CryptoRng,
    {

        // Generators for G1 and G2
        let p1 = E::G1Projective::rand(rng);
        let p2 = E::G2Projective::rand(rng);

        // Scalar intermediate values
        let a1 = E::Fr::rand(rng);
        let a2 = E::Fr::rand(rng);
        let t1 = E::Fr::rand(rng);
        let t2 = E::Fr::rand(rng);

        // Projective intermediate values
        // TODO: OPTIMIZATION -- convert scalar for mul into AsRef<[u64]> to multiply with ProjectiveCurve, if that's more efficient
        let q1 = p1.into_affine().mul(a1);
        let q2 = p2.into_affine().mul(a2);
        let u1 = p1.into_affine().mul(t1);
        let u2 = p2.into_affine().mul(t2);
        let v1: E::G1Projective;
        let v2: E::G2Projective;

        // NOTE: This is supposed to be computationally indistinguishable

        // Instantiate GS key
        if rng.gen_bool(0.5) {
            // Binding
            v1 = q1.into_affine().mul(t1) - E::G1Projective::zero();
            v2 = q2.into_affine().mul(t2) - E::G2Projective::zero();
        }
        else {
            // Hiding
            v1 = q1.into_affine().mul(t1) - p1;
            v2 = q2.into_affine().mul(t2) - p2;
        }

        // TODO: OPTIMIZATION -- Check if ((u1, v1), (u2, v2)) are normalized and (if not) batch
        // normalize by slice before converting into affine equivalents?

        // B1 commitment key for G1
        let u11 = Com1::<E>(p1.into_affine(), q1.into_affine());
        let u12 = Com1::<E>(u1.into_affine(), v1.into_affine());

        // B2 commitment key for G2
        let u21 = Com2::<E>(p2.into_affine(), q2.into_affine());
        let u22 = Com2::<E>(u2.into_affine(), v2.into_affine());

        CRS::<E> {
            u: (u11, u12),
            v: (u21, u22),
            g1_gen: p1.into_affine(),
            g2_gen: p2.into_affine(),
            gt_gen: E::pairing::<E::G1Affine, E::G2Affine>(p1.into_affine(), p2.into_affine())
        }
    }
/// Generates the commitment keys u for G1 and v for G2.
///
/// It should be indistinguishable under the SXDH assumption of the chosen pairing whether u and v were instantiated as a:
///    1) Perfect soundness string (i.e. perfectly binding), or
///    2) Composable witness-indistinguishability string (i.e. perfectly hiding)
Generates the commitment keys u for G1 and v for G2.
It should be indistinguishable under the SXDH assumption of the chosen pairing whether u and v were instantiated as a:
1) Perfect soundness string , or
2) Composable witness-indistinguishability string
Generates the commitment keys u for G1 and v for G2 . It should be indistinguishable under the SXDH assumption of the chosen pairing whether u and v were instantiated as a : 1 ) Perfect soundness string or 2 ) Composable witness - indistinguishability string
pub fn generate_crs<R>(rng: &mut R) -> CRS<E>
    where
        R: Rng + CryptoRng,
    {
        // Generators for G1 and G2
        let p1 = E::G1Projective::rand(rng);
        let p2 = E::G2Projective::rand(rng);
        // Scalar intermediate values
        let a1 = E::Fr::rand(rng);
        let a2 = E::Fr::rand(rng);
        let t1 = E::Fr::rand(rng);
        let t2 = E::Fr::rand(rng);
        // Projective intermediate values
        // TODO: OPTIMIZATION -- convert scalar for mul into AsRef<[u64]> to multiply with ProjectiveCurve, if that's more efficient
        let q1 = p1.into_affine().mul(a1);
        let q2 = p2.into_affine().mul(a2);
        let u1 = p1.into_affine().mul(t1);
        let u2 = p2.into_affine().mul(t2);
        let v1: E::G1Projective;
        let v2: E::G2Projective;
        // NOTE: This is supposed to be computationally indistinguishable
        // Instantiate GS key
        if rng.gen_bool(0.5) {
            // Binding
            v1 = q1.into_affine().mul(t1) - E::G1Projective::zero();
            v2 = q2.into_affine().mul(t2) - E::G2Projective::zero();
        }
        else {
            // Hiding
            v1 = q1.into_affine().mul(t1) - p1;
            v2 = q2.into_affine().mul(t2) - p2;
        }
        // TODO: OPTIMIZATION -- Check if ((u1, v1), (u2, v2)) are normalized and (if not) batch
        // normalize by slice before converting into affine equivalents?
        // B1 commitment key for G1
        let u11 = Com1::<E>(p1.into_affine(), q1.into_affine());
        let u12 = Com1::<E>(u1.into_affine(), v1.into_affine());
        // B2 commitment key for G2
        let u21 = Com2::<E>(p2.into_affine(), q2.into_affine());
        let u22 = Com2::<E>(u2.into_affine(), v2.into_affine());
        CRS::<E> {
            u: (u11, u12),
            v: (u21, u22),
            g1_gen: p1.into_affine(),
            g2_gen: p2.into_affine(),
            gt_gen: E::pairing::<E::G1Affine, E::G2Affine>(p1.into_affine(), p2.into_affine())
        }
    }
pub fn generate_crs < R > ( rng : & mut R ) -> CRS < E > where R : Rng + CryptoRng , { // Generators for G1 and G2 let p1 = E :: G1Projective :: rand ( rng ) ; let p2 = E :: G2Projective :: rand ( rng ) ; // Scalar intermediate values let a1 = E :: Fr :: rand ( rng ) ; let a2 = E :: Fr :: rand ( rng ) ; let t1 = E :: Fr :: rand ( rng ) ; let t2 = E :: Fr :: rand ( rng ) ; // Projective intermediate values // TODO: OPTIMIZATION -- convert scalar for mul into AsRef<[u64]> to multiply with ProjectiveCurve, if that's more efficient let q1 = p1 . into_affine ( ) . mul ( a1 ) ; let q2 = p2 . into_affine ( ) . mul ( a2 ) ; let u1 = p1 . into_affine ( ) . mul ( t1 ) ; let u2 = p2 . into_affine ( ) . mul ( t2 ) ; let v1 : E :: G1Projective ; let v2 : E :: G2Projective ; // NOTE: This is supposed to be computationally indistinguishable // Instantiate GS key if rng . gen_bool ( 0.5 ) { // Binding v1 = q1 . into_affine ( ) . mul ( t1 ) - E :: G1Projective :: zero ( ) ; v2 = q2 . into_affine ( ) . mul ( t2 ) - E :: G2Projective :: zero ( ) ; } else { // Hiding v1 = q1 . into_affine ( ) . mul ( t1 ) - p1 ; v2 = q2 . into_affine ( ) . mul ( t2 ) - p2 ; } // TODO: OPTIMIZATION -- Check if ((u1, v1), (u2, v2)) are normalized and (if not) batch // normalize by slice before converting into affine equivalents? // B1 commitment key for G1 let u11 = Com1 :: < E > ( p1 . into_affine ( ) , q1 . into_affine ( ) ) ; let u12 = Com1 :: < E > ( u1 . into_affine ( ) , v1 . into_affine ( ) ) ; // B2 commitment key for G2 let u21 = Com2 :: < E > ( p2 . into_affine ( ) , q2 . into_affine ( ) ) ; let u22 = Com2 :: < E > ( u2 . into_affine ( ) , v2 . into_affine ( ) ) ; CRS :: < E > { u : ( u11 , u12 ) , v : ( u21 , u22 ) , g1_gen : p1 . into_affine ( ) , g2_gen : p2 . into_affine ( ) , gt_gen : E :: pairing :: < E :: G1Affine , E :: G2Affine > ( p1 . into_affine ( ) , p2 . into_affine ( ) ) } }
Generates the commitment keys u for G1 and v for G2.
Generates the commitment keys u for G1 and v for G2 .
rng
&mut R
rng
&mut R