pub fn verify(
        &self,
        transcript: &mut Transcript,
        vk: &VerifierKey<E>,
        asserted_res_vec: &[Vec<E::Fr>],
        base_polynomials_commitments: &[Commitment<E>],
        direct_base_polynomials_evaluations: &[[E::Fr; 2]],
        fold_randomness: &[Vec<E::Fr>],
        eval_chal: E::Fr,
        batch_challenge: E::Fr,
    ) -> VerificationResult
    where
        E: PairingEngine,
    {
        let minus_eval_chal = -eval_chal;
        let eval_chal2 = eval_chal.square();

        let two_inv = E::Fr::one().double().inverse().unwrap();
        let two_beta_inv = eval_chal.double().inverse().unwrap();

        let mut evaluations = Vec::new();
        evaluations.extend(
            self.base_polynomials_evaluations
                .iter()
                .map(|x| x.to_vec())
                .collect::<Vec<_>>(),
        );

        let mut offset = 0;
        for (instance, randomness) in fold_randomness.iter().enumerate() {
            let rounds = randomness.len() - 1;
            let base_evals = &direct_base_polynomials_evaluations[instance];
            let folded_polynomials_evaluations =
                &self.folded_polynomials_evaluations[offset..offset + rounds];
            let asserted_res = &asserted_res_vec[instance];
            offset += rounds;

            evaluations.push(vec![
                evaluate_sq_fp(
                    &base_evals[0],
                    &base_evals[1],
                    &randomness[0],
                    &two_inv,
                    &two_beta_inv,
                ),
                folded_polynomials_evaluations[0][0],
                folded_polynomials_evaluations[0][1],
            ]);

            for i in 1..rounds {
                evaluations.push(vec![
                    evaluate_sq_fp(
                        &folded_polynomials_evaluations[i - 1][0],
                        &folded_polynomials_evaluations[i - 1][1],
                        &randomness[i],
                        &two_inv,
                        &two_beta_inv,
                    ),
                    folded_polynomials_evaluations[i][0],
                    folded_polynomials_evaluations[i][1],
                ]);
            }

            let subclaim = evaluate_sq_fp(
                &folded_polynomials_evaluations[rounds - 1][0],
                &folded_polynomials_evaluations[rounds - 1][1],
                &randomness[rounds],
                &two_inv,
                &two_beta_inv,
            );

            let batch_challenges = powers(batch_challenge, asserted_res.len());
            let lc_asserted_res = ip(asserted_res, &batch_challenges);

            if subclaim != lc_asserted_res {
                return Err(VerificationError);
            }
        }

        let mut all_commitments = base_polynomials_commitments.to_vec();
        all_commitments.extend(self.folded_polynomials_commitments.iter());

        self.base_polynomials_evaluations
            .iter()
            .flatten()
            .for_each(|e| transcript.append_scalar(b"eval", e));
        self.folded_polynomials_evaluations
            .iter()
            .flatten()
            .for_each(|e| transcript.append_scalar(b"eval", e));
        let open_chal = transcript.get_challenge::<E::Fr>(b"open-chal");

        vk.verify_multi_points(
            &all_commitments,
            &[eval_chal2, eval_chal, minus_eval_chal],
            &evaluations,
            &self.evaluation_proof,
            &open_chal,
        )
    }
/// The function for verifying tensor check proof.
///
/// It takes as input the randomness generator `transcript`, the verifying key `vk`,
/// the asserted result `asserted_res_vec` for each tensor check instance,
/// the commitments `base_polynomials_commitments` for all base polynomials,
/// the evaluations `direct_base_polynomials_evaluations` of base polynomials in each tensor check instance,
/// folding randomnesses `fold_randomness`,
/// the evaluation challenge point `eval_chal`,
/// and the random challenge `batch_challenge` for batching tensor check instances with the same folding randomnesses.
The function for verifying tensor check proof.
The function for verifying tensor check proof .
pub fn verify(
        &self,
        transcript: &mut Transcript,
        vk: &VerifierKey<E>,
        asserted_res_vec: &[Vec<E::Fr>],
        base_polynomials_commitments: &[Commitment<E>],
        direct_base_polynomials_evaluations: &[[E::Fr; 2]],
        fold_randomness: &[Vec<E::Fr>],
        eval_chal: E::Fr,
        batch_challenge: E::Fr,
    ) -> VerificationResult
    where
        E: PairingEngine,
    {
        let minus_eval_chal = -eval_chal;
        let eval_chal2 = eval_chal.square();
        let two_inv = E::Fr::one().double().inverse().unwrap();
        let two_beta_inv = eval_chal.double().inverse().unwrap();
        let mut evaluations = Vec::new();
        evaluations.extend(
            self.base_polynomials_evaluations
                .iter()
                .map(|x| x.to_vec())
                .collect::<Vec<_>>(),
        );
        let mut offset = 0;
        for (instance, randomness) in fold_randomness.iter().enumerate() {
            let rounds = randomness.len() - 1;
            let base_evals = &direct_base_polynomials_evaluations[instance];
            let folded_polynomials_evaluations =
                &self.folded_polynomials_evaluations[offset..offset + rounds];
            let asserted_res = &asserted_res_vec[instance];
            offset += rounds;
            evaluations.push(vec![
                evaluate_sq_fp(
                    &base_evals[0],
                    &base_evals[1],
                    &randomness[0],
                    &two_inv,
                    &two_beta_inv,
                ),
                folded_polynomials_evaluations[0][0],
                folded_polynomials_evaluations[0][1],
            ]);
            for i in 1..rounds {
                evaluations.push(vec![
                    evaluate_sq_fp(
                        &folded_polynomials_evaluations[i - 1][0],
                        &folded_polynomials_evaluations[i - 1][1],
                        &randomness[i],
                        &two_inv,
                        &two_beta_inv,
                    ),
                    folded_polynomials_evaluations[i][0],
                    folded_polynomials_evaluations[i][1],
                ]);
            }
            let subclaim = evaluate_sq_fp(
                &folded_polynomials_evaluations[rounds - 1][0],
                &folded_polynomials_evaluations[rounds - 1][1],
                &randomness[rounds],
                &two_inv,
                &two_beta_inv,
            );
            let batch_challenges = powers(batch_challenge, asserted_res.len());
            let lc_asserted_res = ip(asserted_res, &batch_challenges);
            if subclaim != lc_asserted_res {
                return Err(VerificationError);
            }
        }
        let mut all_commitments = base_polynomials_commitments.to_vec();
        all_commitments.extend(self.folded_polynomials_commitments.iter());
        self.base_polynomials_evaluations
            .iter()
            .flatten()
            .for_each(|e| transcript.append_scalar(b"eval", e));
        self.folded_polynomials_evaluations
            .iter()
            .flatten()
            .for_each(|e| transcript.append_scalar(b"eval", e));
        let open_chal = transcript.get_challenge::<E::Fr>(b"open-chal");
        vk.verify_multi_points(
            &all_commitments,
            &[eval_chal2, eval_chal, minus_eval_chal],
            &evaluations,
            &self.evaluation_proof,
            &open_chal,
        )
    }
pub fn verify ( & self , transcript : & mut Transcript , vk : & VerifierKey < E > , asserted_res_vec : & [ Vec < E :: Fr > ] , base_polynomials_commitments : & [ Commitment < E > ] , direct_base_polynomials_evaluations : & [ [ E :: Fr ; 2 ] ] , fold_randomness : & [ Vec < E :: Fr > ] , eval_chal : E :: Fr , batch_challenge : E :: Fr , ) -> VerificationResult where E : PairingEngine , { let minus_eval_chal = - eval_chal ; let eval_chal2 = eval_chal . square ( ) ; let two_inv = E :: Fr :: one ( ) . double ( ) . inverse ( ) . unwrap ( ) ; let two_beta_inv = eval_chal . double ( ) . inverse ( ) . unwrap ( ) ; let mut evaluations = Vec :: new ( ) ; evaluations . extend ( self . base_polynomials_evaluations . iter ( ) . map ( | x | x . to_vec ( ) ) . collect :: < Vec < _ > > ( ) , ) ; let mut offset = 0 ; for ( instance , randomness ) in fold_randomness . iter ( ) . enumerate ( ) { let rounds = randomness . len ( ) - 1 ; let base_evals = & direct_base_polynomials_evaluations [ instance ] ; let folded_polynomials_evaluations = & self . folded_polynomials_evaluations [ offset .. offset + rounds ] ; let asserted_res = & asserted_res_vec [ instance ] ; offset += rounds ; evaluations . push ( vec ! [ evaluate_sq_fp ( base_evals [ 0 ] base_evals [ 1 ] randomness [ 0 ] two_inv two_beta_inv ) folded_polynomials_evaluations [ 0 ] [ 0 ] folded_polynomials_evaluations [ 0 ] [ 1 ] ] ) ; for i in 1 .. rounds { evaluations . push ( vec ! [ evaluate_sq_fp ( folded_polynomials_evaluations [ i 1 ] [ 0 ] folded_polynomials_evaluations [ i 1 ] [ 1 ] randomness [ i ] two_inv two_beta_inv ) folded_polynomials_evaluations [ i ] [ 0 ] folded_polynomials_evaluations [ i ] [ 1 ] ] ) ; } let subclaim = evaluate_sq_fp ( & folded_polynomials_evaluations [ rounds - 1 ] [ 0 ] , & folded_polynomials_evaluations [ rounds - 1 ] [ 1 ] , & randomness [ rounds ] , & two_inv , & two_beta_inv , ) ; let batch_challenges = powers ( batch_challenge , asserted_res . len ( ) ) ; let lc_asserted_res = ip ( asserted_res , & batch_challenges ) ; if subclaim != lc_asserted_res { return Err ( VerificationError ) ; } } let mut all_commitments = base_polynomials_commitments . to_vec ( ) ; all_commitments . extend ( self . folded_polynomials_commitments . iter ( ) ) ; self . base_polynomials_evaluations . iter ( ) . flatten ( ) . for_each ( | e | transcript . append_scalar ( b" " , e ) ) ; self . folded_polynomials_evaluations . iter ( ) . flatten ( ) . for_each ( | e | transcript . append_scalar ( b" " , e ) ) ; let open_chal = transcript . get_challenge :: < E :: Fr > ( b" " ) ; vk . verify_multi_points ( & all_commitments , & [ eval_chal2 , eval_chal , minus_eval_chal ] , & evaluations , & self . evaluation_proof , & open_chal , ) }
The function for verifying tensor check proof.
The function for verifying tensor check proof .
&self
transcript
&mut Transcript
vk
&VerifierKey<E>
asserted_res_vec
&[Vec<E::Fr>]
base_polynomials_commitments
&[Commitment<E>]
direct_base_polynomials_evaluations
&[[E::Fr; 2]]
fold_randomness
&[Vec<E::Fr>]
eval_chal
E::Fr
batch_challenge
E::Fr