fn commit<'a>(
        ck: &Self::CommitterKey,
        polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<E::Fr, P>>,
        rng: Option<&mut dyn RngCore>,
    ) -> Result<
        (
            Vec<LabeledCommitment<Self::Commitment>>,
            Vec<Self::Randomness>,
        ),
        Self::Error,
    >
    where
        P: 'a,
    {
        let rng = &mut crate::optional_rng::OptionalRng(rng);
        let commit_time = start_timer!(|| "Committing to polynomials");
        let mut commitments = Vec::new();
        let mut randomness = Vec::new();
        for p in polynomials {
            let label = p.label();
            let hiding_bound = p.hiding_bound();
            let polynomial: &P = p.polynomial();
            Self::check_degrees_and_bounds(ck.supported_degree, &p)?;

            let commit_time = start_timer!(|| {
                format!(
                    "Polynomial {} with degree {} and hiding bound {:?}",
                    label,
                    polynomial.degree(),
                    hiding_bound,
                )
            });
            // Get the powers of `G` corresponding to the terms of `polynomial`
            let powers_of_g = ark_std::cfg_iter!(polynomial.terms())
                .map(|(_, term)| *ck.powers_of_g.get(term).unwrap())
                .collect::<Vec<_>>();
            // Convert coefficients of `polynomial` to BigInts
            let to_bigint_time = start_timer!(|| "Converting polynomial coeffs to bigints");
            let plain_ints = Self::convert_to_bigints(&polynomial);
            end_timer!(to_bigint_time);

            let msm_time = start_timer!(|| "MSM to compute commitment to plaintext poly");
            let mut commitment = VariableBase::msm(&powers_of_g, &plain_ints);
            end_timer!(msm_time);

            // Sample random polynomial
            let mut rand = Randomness::<E, P>::empty();
            if let Some(hiding_degree) = hiding_bound {
                let sample_random_poly_time = start_timer!(|| format!(
                    "Sampling a random polynomial of degree {}",
                    hiding_degree
                ));
                rand = Randomness::rand(hiding_degree, false, Some(ck.num_vars), rng);
                Self::check_hiding_bound(hiding_degree, ck.supported_degree + 1)?;
                end_timer!(sample_random_poly_time);
            }

            // Get the powers of `\gamma G` corresponding to the terms of `rand`
            let powers_of_gamma_g = rand
                .blinding_polynomial
                .terms()
                .iter()
                .map(|(_, term)| {
                    // Implicit Assumption: Each monomial in `rand` is univariate
                    let vars = term.vars();
                    match term.is_constant() {
                        true => ck.gamma_g,
                        false => ck.powers_of_gamma_g[vars[0]][term.degree() - 1],
                    }
                })
                .collect::<Vec<_>>();
            // Convert coefficients of `rand` to BigInt
            let to_bigint_time = start_timer!(|| "Converting polynomial coeffs to bigints");
            let random_ints = Self::convert_to_bigints(&rand.blinding_polynomial);
            end_timer!(to_bigint_time);

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

            // Mask commitment with random poly
            commitment.add_assign_mixed(&random_commitment);

            let comm = Self::Commitment {
                comm: kzg10::Commitment(commitment.into()),
                shifted_comm: None,
            };

            commitments.push(LabeledCommitment::new(label.to_string(), comm, None));
            randomness.push(rand);
            end_timer!(commit_time);
        }
        end_timer!(commit_time);
        Ok((commitments, randomness))
    }
/// Outputs a commitments to `polynomials`.
Outputs a commitments to `polynomials`.
Outputs a commitments to ` polynomials ` .
fn commit<'a>(
        ck: &Self::CommitterKey,
        polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<E::Fr, P>>,
        rng: Option<&mut dyn RngCore>,
    ) -> Result<
        (
            Vec<LabeledCommitment<Self::Commitment>>,
            Vec<Self::Randomness>,
        ),
        Self::Error,
    >
    where
        P: 'a,
    {
        let rng = &mut crate::optional_rng::OptionalRng(rng);
        let commit_time = start_timer!(|| "Committing to polynomials");
        let mut commitments = Vec::new();
        let mut randomness = Vec::new();
        for p in polynomials {
            let label = p.label();
            let hiding_bound = p.hiding_bound();
            let polynomial: &P = p.polynomial();
            Self::check_degrees_and_bounds(ck.supported_degree, &p)?;
            let commit_time = start_timer!(|| {
                format!(
                    "Polynomial {} with degree {} and hiding bound {:?}",
                    label,
                    polynomial.degree(),
                    hiding_bound,
                )
            });
            // Get the powers of `G` corresponding to the terms of `polynomial`
            let powers_of_g = ark_std::cfg_iter!(polynomial.terms())
                .map(|(_, term)| *ck.powers_of_g.get(term).unwrap())
                .collect::<Vec<_>>();
            // Convert coefficients of `polynomial` to BigInts
            let to_bigint_time = start_timer!(|| "Converting polynomial coeffs to bigints");
            let plain_ints = Self::convert_to_bigints(&polynomial);
            end_timer!(to_bigint_time);
            let msm_time = start_timer!(|| "MSM to compute commitment to plaintext poly");
            let mut commitment = VariableBase::msm(&powers_of_g, &plain_ints);
            end_timer!(msm_time);
            // Sample random polynomial
            let mut rand = Randomness::<E, P>::empty();
            if let Some(hiding_degree) = hiding_bound {
                let sample_random_poly_time = start_timer!(|| format!(
                    "Sampling a random polynomial of degree {}",
                    hiding_degree
                ));
                rand = Randomness::rand(hiding_degree, false, Some(ck.num_vars), rng);
                Self::check_hiding_bound(hiding_degree, ck.supported_degree + 1)?;
                end_timer!(sample_random_poly_time);
            }
            // Get the powers of `\gamma G` corresponding to the terms of `rand`
            let powers_of_gamma_g = rand
                .blinding_polynomial
                .terms()
                .iter()
                .map(|(_, term)| {
                    // Implicit Assumption: Each monomial in `rand` is univariate
                    let vars = term.vars();
                    match term.is_constant() {
                        true => ck.gamma_g,
                        false => ck.powers_of_gamma_g[vars[0]][term.degree() - 1],
                    }
                })
                .collect::<Vec<_>>();
            // Convert coefficients of `rand` to BigInt
            let to_bigint_time = start_timer!(|| "Converting polynomial coeffs to bigints");
            let random_ints = Self::convert_to_bigints(&rand.blinding_polynomial);
            end_timer!(to_bigint_time);
            let msm_time = start_timer!(|| "MSM to compute commitment to random poly");
            let random_commitment =
                VariableBase::msm(&powers_of_gamma_g, &random_ints).into_affine();
            end_timer!(msm_time);
            // Mask commitment with random poly
            commitment.add_assign_mixed(&random_commitment);
            let comm = Self::Commitment {
                comm: kzg10::Commitment(commitment.into()),
                shifted_comm: None,
            };
            commitments.push(LabeledCommitment::new(label.to_string(), comm, None));
            randomness.push(rand);
            end_timer!(commit_time);
        }
        end_timer!(commit_time);
        Ok((commitments, randomness))
    }
fn commit < ' a > ( ck : & Self :: CommitterKey , polynomials : impl IntoIterator < Item = & ' a LabeledPolynomial < E :: Fr , P > > , rng : Option < & mut dyn RngCore > , ) -> Result < ( Vec < LabeledCommitment < Self :: Commitment > > , Vec < Self :: Randomness > , ) , Self :: Error , > where P : ' a , { let rng = & mut crate :: optional_rng :: OptionalRng ( rng ) ; let commit_time = start_timer ! ( " " ) ; let mut commitments = Vec :: new ( ) ; let mut randomness = Vec :: new ( ) ; for p in polynomials { let label = p . label ( ) ; let hiding_bound = p . hiding_bound ( ) ; let polynomial : & P = p . polynomial ( ) ; Self :: check_degrees_and_bounds ( ck . supported_degree , & p ) ? ; let commit_time = start_timer ! ( { format ( " " label polynomial degree ( ) hiding_bound ) } ) ; // Get the powers of `G` corresponding to the terms of `polynomial` let powers_of_g = ark_std :: cfg_iter ! ( polynomial terms ( ) ) . map ( | ( _ , term ) | * ck . powers_of_g . get ( term ) . unwrap ( ) ) . collect :: < Vec < _ > > ( ) ; // Convert coefficients of `polynomial` to BigInts let to_bigint_time = start_timer ! ( " " ) ; let plain_ints = Self :: convert_to_bigints ( & polynomial ) ; end_timer ! ( to_bigint_time ) ; let msm_time = start_timer ! ( " " ) ; let mut commitment = VariableBase :: msm ( & powers_of_g , & plain_ints ) ; end_timer ! ( msm_time ) ; // Sample random polynomial let mut rand = Randomness :: < E , P > :: empty ( ) ; if let Some ( hiding_degree ) = hiding_bound { let sample_random_poly_time = start_timer ! ( format ( " " hiding_degree ) ) ; rand = Randomness :: rand ( hiding_degree , false , Some ( ck . num_vars ) , rng ) ; Self :: check_hiding_bound ( hiding_degree , ck . supported_degree + 1 ) ? ; end_timer ! ( sample_random_poly_time ) ; } // Get the powers of `\gamma G` corresponding to the terms of `rand` let powers_of_gamma_g = rand . blinding_polynomial . terms ( ) . iter ( ) . map ( | ( _ , term ) | { // Implicit Assumption: Each monomial in `rand` is univariate let vars = term . vars ( ) ; match term . is_constant ( ) { true => ck . gamma_g , false => ck . powers_of_gamma_g [ vars [ 0 ] ] [ term . degree ( ) - 1 ] , } } ) . collect :: < Vec < _ > > ( ) ; // Convert coefficients of `rand` to BigInt let to_bigint_time = start_timer ! ( " " ) ; let random_ints = Self :: convert_to_bigints ( & rand . blinding_polynomial ) ; end_timer ! ( to_bigint_time ) ; let msm_time = start_timer ! ( " " ) ; let random_commitment = VariableBase :: msm ( & powers_of_gamma_g , & random_ints ) . into_affine ( ) ; end_timer ! ( msm_time ) ; // Mask commitment with random poly commitment . add_assign_mixed ( & random_commitment ) ; let comm = Self :: Commitment { comm : kzg10 :: Commitment ( commitment . into ( ) ) , shifted_comm : None , } ; commitments . push ( LabeledCommitment :: new ( label . to_string ( ) , comm , None ) ) ; randomness . push ( rand ) ; end_timer ! ( commit_time ) ; } end_timer ! ( commit_time ) ; Ok ( ( commitments , randomness ) ) }
Outputs a commitments to `polynomials`.
Outputs a commitments to ` polynomials ` .
ck
&Self::CommitterKey
polynomials
impl IntoIterator<Item = &'a LabeledPolynomial<E::Fr, P>>
rng
Option<&mut dyn RngCore>