pub fn commit(
        powers: &Powers<E>,
        polynomial: &P,
        hiding_bound: Option<usize>,
        rng: Option<&mut dyn RngCore>,
    ) -> Result<(Commitment<E>, Randomness<E::Fr, P>), Error> {
        Self::check_degree_is_too_large(polynomial.degree(), powers.size())?;

        let commit_time = start_timer!(|| format!(
            "Committing to polynomial of degree {} with hiding_bound: {:?}",
            polynomial.degree(),
            hiding_bound,
        ));

        let (num_leading_zeros, plain_coeffs) =
            skip_leading_zeros_and_convert_to_bigints(polynomial);

        let msm_time = start_timer!(|| "MSM to compute commitment to plaintext poly");
        let mut commitment =
            VariableBase::msm(&powers.powers_of_g[num_leading_zeros..], &plain_coeffs);
        end_timer!(msm_time);

        let mut randomness = Randomness::<E::Fr, P>::empty();
        if let Some(hiding_degree) = hiding_bound {
            let mut rng = rng.ok_or(Error::MissingRng)?;
            let sample_random_poly_time = start_timer!(|| format!(
                "Sampling a random polynomial of degree {}",
                hiding_degree
            ));

            randomness = Randomness::rand(hiding_degree, false, None, &mut rng);
            Self::check_hiding_bound(
                randomness.blinding_polynomial.degree(),
                powers.powers_of_gamma_g.len(),
            )?;
            end_timer!(sample_random_poly_time);
        }

        let random_ints = convert_to_bigints(&randomness.blinding_polynomial.coeffs());
        let msm_time = start_timer!(|| "MSM to compute commitment to random poly");
        let random_commitment =
            VariableBase::msm(&powers.powers_of_gamma_g, random_ints.as_slice()).into_affine();
        end_timer!(msm_time);

        commitment.add_assign_mixed(&random_commitment);

        end_timer!(commit_time);
        Ok((Commitment(commitment.into()), randomness))
    }
/// Outputs a commitment to `polynomial`.
Outputs a commitment to `polynomial`.
Outputs a commitment to ` polynomial ` .
pub fn commit(
        powers: &Powers<E>,
        polynomial: &P,
        hiding_bound: Option<usize>,
        rng: Option<&mut dyn RngCore>,
    ) -> Result<(Commitment<E>, Randomness<E::Fr, P>), Error> {
        Self::check_degree_is_too_large(polynomial.degree(), powers.size())?;
        let commit_time = start_timer!(|| format!(
            "Committing to polynomial of degree {} with hiding_bound: {:?}",
            polynomial.degree(),
            hiding_bound,
        ));
        let (num_leading_zeros, plain_coeffs) =
            skip_leading_zeros_and_convert_to_bigints(polynomial);
        let msm_time = start_timer!(|| "MSM to compute commitment to plaintext poly");
        let mut commitment =
            VariableBase::msm(&powers.powers_of_g[num_leading_zeros..], &plain_coeffs);
        end_timer!(msm_time);
        let mut randomness = Randomness::<E::Fr, P>::empty();
        if let Some(hiding_degree) = hiding_bound {
            let mut rng = rng.ok_or(Error::MissingRng)?;
            let sample_random_poly_time = start_timer!(|| format!(
                "Sampling a random polynomial of degree {}",
                hiding_degree
            ));
            randomness = Randomness::rand(hiding_degree, false, None, &mut rng);
            Self::check_hiding_bound(
                randomness.blinding_polynomial.degree(),
                powers.powers_of_gamma_g.len(),
            )?;
            end_timer!(sample_random_poly_time);
        }
        let random_ints = convert_to_bigints(&randomness.blinding_polynomial.coeffs());
        let msm_time = start_timer!(|| "MSM to compute commitment to random poly");
        let random_commitment =
            VariableBase::msm(&powers.powers_of_gamma_g, random_ints.as_slice()).into_affine();
        end_timer!(msm_time);
        commitment.add_assign_mixed(&random_commitment);
        end_timer!(commit_time);
        Ok((Commitment(commitment.into()), randomness))
    }
pub fn commit ( powers : & Powers < E > , polynomial : & P , hiding_bound : Option < usize > , rng : Option < & mut dyn RngCore > , ) -> Result < ( Commitment < E > , Randomness < E :: Fr , P > ) , Error > { Self :: check_degree_is_too_large ( polynomial . degree ( ) , powers . size ( ) ) ? ; let commit_time = start_timer ! ( format ( " " polynomial degree ( ) hiding_bound ) ) ; let ( num_leading_zeros , plain_coeffs ) = skip_leading_zeros_and_convert_to_bigints ( polynomial ) ; let msm_time = start_timer ! ( " " ) ; let mut commitment = VariableBase :: msm ( & powers . powers_of_g [ num_leading_zeros .. ] , & plain_coeffs ) ; end_timer ! ( msm_time ) ; let mut randomness = Randomness :: < E :: Fr , P > :: empty ( ) ; if let Some ( hiding_degree ) = hiding_bound { let mut rng = rng . ok_or ( Error :: MissingRng ) ? ; let sample_random_poly_time = start_timer ! ( format ( " " hiding_degree ) ) ; randomness = Randomness :: rand ( hiding_degree , false , None , & mut rng ) ; Self :: check_hiding_bound ( randomness . blinding_polynomial . degree ( ) , powers . powers_of_gamma_g . len ( ) , ) ? ; end_timer ! ( sample_random_poly_time ) ; } let random_ints = convert_to_bigints ( & randomness . blinding_polynomial . coeffs ( ) ) ; let msm_time = start_timer ! ( " " ) ; let random_commitment = VariableBase :: msm ( & powers . powers_of_gamma_g , random_ints . as_slice ( ) ) . into_affine ( ) ; end_timer ! ( msm_time ) ; commitment . add_assign_mixed ( & random_commitment ) ; end_timer ! ( commit_time ) ; Ok ( ( Commitment ( commitment . into ( ) ) , randomness ) ) }
Outputs a commitment to `polynomial`.
Outputs a commitment to ` polynomial ` .
powers
&Powers<E>
polynomial
&P
hiding_bound
Option<usize>
rng
Option<&mut dyn RngCore>