fn succinct_check<'a>(
        vk: &VerifierKey<G>,
        commitments: impl IntoIterator<Item = &'a LabeledCommitment<Commitment<G>>>,
        point: G::ScalarField,
        values: impl IntoIterator<Item = G::ScalarField>,
        proof: &Proof<G>,
        opening_challenges: &mut ChallengeGenerator<G::ScalarField, S>,
    ) -> Option<SuccinctCheckPolynomial<G::ScalarField>> {
        let check_time = start_timer!(|| "Succinct checking");

        let d = vk.supported_degree();

        // `log_d` is ceil(log2 (d + 1)), which is the number of steps to compute all of the challenges
        let log_d = ark_std::log2(d + 1) as usize;

        let mut combined_commitment_proj = G::Projective::zero();
        let mut combined_v = G::ScalarField::zero();

        let mut cur_challenge = opening_challenges.try_next_challenge_of_size(CHALLENGE_SIZE);

        let labeled_commitments = commitments.into_iter();
        let values = values.into_iter();

        for (labeled_commitment, value) in labeled_commitments.zip(values) {
            let commitment = labeled_commitment.commitment();
            combined_v += &(cur_challenge * &value);
            combined_commitment_proj += &labeled_commitment.commitment().comm.mul(cur_challenge);
            cur_challenge = opening_challenges.try_next_challenge_of_size(CHALLENGE_SIZE);

            let degree_bound = labeled_commitment.degree_bound();
            assert_eq!(degree_bound.is_some(), commitment.shifted_comm.is_some());

            if let Some(degree_bound) = degree_bound {
                let shift = point.pow([(vk.supported_degree() - degree_bound) as u64]);
                combined_v += &(cur_challenge * &value * &shift);
                combined_commitment_proj += &commitment.shifted_comm.unwrap().mul(cur_challenge);
            }

            cur_challenge = opening_challenges.try_next_challenge_of_size(CHALLENGE_SIZE);
        }

        let mut combined_commitment = combined_commitment_proj.into_affine();

        assert_eq!(proof.hiding_comm.is_some(), proof.rand.is_some());
        if proof.hiding_comm.is_some() {
            let hiding_comm = proof.hiding_comm.unwrap();
            let rand = proof.rand.unwrap();

            let hiding_challenge = Self::compute_random_oracle_challenge(
                &ark_ff::to_bytes![combined_commitment, point, combined_v, hiding_comm].unwrap(),
            );
            combined_commitment_proj += &(hiding_comm.mul(hiding_challenge) - &vk.s.mul(rand));
            combined_commitment = combined_commitment_proj.into_affine();
        }

        // Challenge for each round
        let mut round_challenges = Vec::with_capacity(log_d);
        let mut round_challenge = Self::compute_random_oracle_challenge(
            &ark_ff::to_bytes![combined_commitment, point, combined_v].unwrap(),
        );

        let h_prime = vk.h.mul(round_challenge);

        let mut round_commitment_proj =
            combined_commitment_proj + &h_prime.mul(&combined_v.into_bigint());

        let l_iter = proof.l_vec.iter();
        let r_iter = proof.r_vec.iter();

        for (l, r) in l_iter.zip(r_iter) {
            round_challenge = Self::compute_random_oracle_challenge(
                &ark_ff::to_bytes![round_challenge, l, r].unwrap(),
            );
            round_challenges.push(round_challenge);
            round_commitment_proj +=
                &(l.mul(round_challenge.inverse().unwrap()) + &r.mul(round_challenge));
        }

        let check_poly = SuccinctCheckPolynomial::<G::ScalarField>(round_challenges);
        let v_prime = check_poly.evaluate(point) * &proof.c;
        let h_prime = h_prime.into_affine();

        let check_commitment_elem: G::Projective = Self::cm_commit(
            &[proof.final_comm_key.clone(), h_prime],
            &[proof.c.clone(), v_prime],
            None,
            None,
        );

        if !(round_commitment_proj - &check_commitment_elem).is_zero() {
            end_timer!(check_time);
            return None;
        }

        end_timer!(check_time);
        Some(check_poly)
    }
/// The succinct portion of `PC::check`. This algorithm runs in time
/// O(log d), where d is the degree of the committed polynomials.
The succinct portion of `PC::check`. This algorithm runs in time
O(log d), where d is the degree of the committed polynomials.
The succinct portion of ` PC :: check ` . This algorithm runs in time O ( log d ) where d is the degree of the committed polynomials .
fn succinct_check<'a>(
        vk: &VerifierKey<G>,
        commitments: impl IntoIterator<Item = &'a LabeledCommitment<Commitment<G>>>,
        point: G::ScalarField,
        values: impl IntoIterator<Item = G::ScalarField>,
        proof: &Proof<G>,
        opening_challenges: &mut ChallengeGenerator<G::ScalarField, S>,
    ) -> Option<SuccinctCheckPolynomial<G::ScalarField>> {
        let check_time = start_timer!(|| "Succinct checking");
        let d = vk.supported_degree();
        // `log_d` is ceil(log2 (d + 1)), which is the number of steps to compute all of the challenges
        let log_d = ark_std::log2(d + 1) as usize;
        let mut combined_commitment_proj = G::Projective::zero();
        let mut combined_v = G::ScalarField::zero();
        let mut cur_challenge = opening_challenges.try_next_challenge_of_size(CHALLENGE_SIZE);
        let labeled_commitments = commitments.into_iter();
        let values = values.into_iter();
        for (labeled_commitment, value) in labeled_commitments.zip(values) {
            let commitment = labeled_commitment.commitment();
            combined_v += &(cur_challenge * &value);
            combined_commitment_proj += &labeled_commitment.commitment().comm.mul(cur_challenge);
            cur_challenge = opening_challenges.try_next_challenge_of_size(CHALLENGE_SIZE);
            let degree_bound = labeled_commitment.degree_bound();
            assert_eq!(degree_bound.is_some(), commitment.shifted_comm.is_some());
            if let Some(degree_bound) = degree_bound {
                let shift = point.pow([(vk.supported_degree() - degree_bound) as u64]);
                combined_v += &(cur_challenge * &value * &shift);
                combined_commitment_proj += &commitment.shifted_comm.unwrap().mul(cur_challenge);
            }
            cur_challenge = opening_challenges.try_next_challenge_of_size(CHALLENGE_SIZE);
        }
        let mut combined_commitment = combined_commitment_proj.into_affine();
        assert_eq!(proof.hiding_comm.is_some(), proof.rand.is_some());
        if proof.hiding_comm.is_some() {
            let hiding_comm = proof.hiding_comm.unwrap();
            let rand = proof.rand.unwrap();
            let hiding_challenge = Self::compute_random_oracle_challenge(
                &ark_ff::to_bytes![combined_commitment, point, combined_v, hiding_comm].unwrap(),
            );
            combined_commitment_proj += &(hiding_comm.mul(hiding_challenge) - &vk.s.mul(rand));
            combined_commitment = combined_commitment_proj.into_affine();
        }
        // Challenge for each round
        let mut round_challenges = Vec::with_capacity(log_d);
        let mut round_challenge = Self::compute_random_oracle_challenge(
            &ark_ff::to_bytes![combined_commitment, point, combined_v].unwrap(),
        );
        let h_prime = vk.h.mul(round_challenge);
        let mut round_commitment_proj =
            combined_commitment_proj + &h_prime.mul(&combined_v.into_bigint());
        let l_iter = proof.l_vec.iter();
        let r_iter = proof.r_vec.iter();
        for (l, r) in l_iter.zip(r_iter) {
            round_challenge = Self::compute_random_oracle_challenge(
                &ark_ff::to_bytes![round_challenge, l, r].unwrap(),
            );
            round_challenges.push(round_challenge);
            round_commitment_proj +=
                &(l.mul(round_challenge.inverse().unwrap()) + &r.mul(round_challenge));
        }
        let check_poly = SuccinctCheckPolynomial::<G::ScalarField>(round_challenges);
        let v_prime = check_poly.evaluate(point) * &proof.c;
        let h_prime = h_prime.into_affine();
        let check_commitment_elem: G::Projective = Self::cm_commit(
            &[proof.final_comm_key.clone(), h_prime],
            &[proof.c.clone(), v_prime],
            None,
            None,
        );
        if !(round_commitment_proj - &check_commitment_elem).is_zero() {
            end_timer!(check_time);
            return None;
        }
        end_timer!(check_time);
        Some(check_poly)
    }
fn succinct_check < ' a > ( vk : & VerifierKey < G > , commitments : impl IntoIterator < Item = & ' a LabeledCommitment < Commitment < G > > > , point : G :: ScalarField , values : impl IntoIterator < Item = G :: ScalarField > , proof : & Proof < G > , opening_challenges : & mut ChallengeGenerator < G :: ScalarField , S > , ) -> Option < SuccinctCheckPolynomial < G :: ScalarField > > { let check_time = start_timer ! ( " " ) ; let d = vk . supported_degree ( ) ; // `log_d` is ceil(log2 (d + 1)), which is the number of steps to compute all of the challenges let log_d = ark_std :: log2 ( d + 1 ) as usize ; let mut combined_commitment_proj = G :: Projective :: zero ( ) ; let mut combined_v = G :: ScalarField :: zero ( ) ; let mut cur_challenge = opening_challenges . try_next_challenge_of_size ( CHALLENGE_SIZE ) ; let labeled_commitments = commitments . into_iter ( ) ; let values = values . into_iter ( ) ; for ( labeled_commitment , value ) in labeled_commitments . zip ( values ) { let commitment = labeled_commitment . commitment ( ) ; combined_v += & ( cur_challenge * & value ) ; combined_commitment_proj += & labeled_commitment . commitment ( ) . comm . mul ( cur_challenge ) ; cur_challenge = opening_challenges . try_next_challenge_of_size ( CHALLENGE_SIZE ) ; let degree_bound = labeled_commitment . degree_bound ( ) ; assert_eq ! ( degree_bound is_some ( ) commitment shifted_comm is_some ( ) ) ; if let Some ( degree_bound ) = degree_bound { let shift = point . pow ( [ ( vk . supported_degree ( ) - degree_bound ) as u64 ] ) ; combined_v += & ( cur_challenge * & value * & shift ) ; combined_commitment_proj += & commitment . shifted_comm . unwrap ( ) . mul ( cur_challenge ) ; } cur_challenge = opening_challenges . try_next_challenge_of_size ( CHALLENGE_SIZE ) ; } let mut combined_commitment = combined_commitment_proj . into_affine ( ) ; assert_eq ! ( proof hiding_comm is_some ( ) proof rand is_some ( ) ) ; if proof . hiding_comm . is_some ( ) { let hiding_comm = proof . hiding_comm . unwrap ( ) ; let rand = proof . rand . unwrap ( ) ; let hiding_challenge = Self :: compute_random_oracle_challenge ( & ark_ff :: to_bytes ! [ combined_commitment point combined_v hiding_comm ] . unwrap ( ) , ) ; combined_commitment_proj += & ( hiding_comm . mul ( hiding_challenge ) - & vk . s . mul ( rand ) ) ; combined_commitment = combined_commitment_proj . into_affine ( ) ; } // Challenge for each round let mut round_challenges = Vec :: with_capacity ( log_d ) ; let mut round_challenge = Self :: compute_random_oracle_challenge ( & ark_ff :: to_bytes ! [ combined_commitment point combined_v ] . unwrap ( ) , ) ; let h_prime = vk . h . mul ( round_challenge ) ; let mut round_commitment_proj = combined_commitment_proj + & h_prime . mul ( & combined_v . into_bigint ( ) ) ; let l_iter = proof . l_vec . iter ( ) ; let r_iter = proof . r_vec . iter ( ) ; for ( l , r ) in l_iter . zip ( r_iter ) { round_challenge = Self :: compute_random_oracle_challenge ( & ark_ff :: to_bytes ! [ round_challenge l r ] . unwrap ( ) , ) ; round_challenges . push ( round_challenge ) ; round_commitment_proj += & ( l . mul ( round_challenge . inverse ( ) . unwrap ( ) ) + & r . mul ( round_challenge ) ) ; } let check_poly = SuccinctCheckPolynomial :: < G :: ScalarField > ( round_challenges ) ; let v_prime = check_poly . evaluate ( point ) * & proof . c ; let h_prime = h_prime . into_affine ( ) ; let check_commitment_elem : G :: Projective = Self :: cm_commit ( & [ proof . final_comm_key . clone ( ) , h_prime ] , & [ proof . c . clone ( ) , v_prime ] , None , None , ) ; if ! ( round_commitment_proj - & check_commitment_elem ) . is_zero ( ) { end_timer ! ( check_time ) ; return None ; } end_timer ! ( check_time ) ; Some ( check_poly ) }
The succinct portion of `PC::check`.
The succinct portion of ` PC :: check ` .
vk
&VerifierKey<G>
commitments
impl IntoIterator<Item = &'a LabeledCommitment<Commitment<G>>>
point
G::ScalarField
values
impl IntoIterator<Item = G::ScalarField>
proof
&Proof<G>
opening_challenges
&mut ChallengeGenerator<G::ScalarField, S>