pub fn tensorcheck<F, E, SG, SB, SF1>(
    transcript: &mut Transcript,
    ck: CommitterKeyStream<E, SG>,
    base_polynomial: &SB,
    body_polynomials: (&SF1, &[F]),
    max_msm_buffer: usize,
) -> TensorcheckProof<E>
where
    F: Field,
    E: PairingEngine<Fr = F>,
    SG: Iterable,
    SG::Item: Borrow<E::G1Affine>,
    SB: Iterable,
    SB::Item: Borrow<E::Fr>,
    SF1: Iterable<Item = F>,
{
    let tensorcheck_challenges = strip_last(body_polynomials.1);
    let tensorcheck_foldings =
        FoldedPolynomialTree::new(body_polynomials.0, tensorcheck_challenges);
    let folded_polynomials_commitments = ck.commit_folding(&tensorcheck_foldings, max_msm_buffer);

    // add commitments to transcript
    folded_polynomials_commitments
        .iter()
        .for_each(|c| transcript.append_commitment(b"commitment", c));
    let eval_chal = transcript.get_challenge::<E::Fr>(b"evaluation-chal");
    let eval_points = [eval_chal.square(), eval_chal, -eval_chal];

    let folded_polynomials_evaluations = evaluate_folding(&tensorcheck_foldings, eval_points[1])
        .into_iter()
        .zip(evaluate_folding(&tensorcheck_foldings, eval_points[2]))
        .map(|(x, y)| [x, y])
        .collect::<Vec<_>>();
    let evaluations_w = [
        evaluate_be(base_polynomial.iter(), &eval_points[0]),
        evaluate_be(base_polynomial.iter(), &eval_points[1]),
        evaluate_be(base_polynomial.iter(), &eval_points[2]),
    ];
    evaluations_w
        .iter()
        .for_each(|e| transcript.append_scalar(b"eval", &e));
    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");
    let open_chal_len = body_polynomials.1.len() + 1;
    let open_chals = powers(open_chal, open_chal_len);

    let (_, proof_w) = ck.open_multi_points(base_polynomial, &eval_points, max_msm_buffer);
    let (_, proof) = ck.open_folding(
        tensorcheck_foldings,
        &eval_points,
        &open_chals[1..],
        max_msm_buffer,
    );
    let evaluation_proof = proof_w + proof;
    TensorcheckProof {
        folded_polynomials_commitments,
        folded_polynomials_evaluations,
        evaluation_proof,
        base_polynomials_evaluations: vec![evaluations_w],
    }
}
/// Streaming function for producing the tensor check proof.
Streaming function for producing the tensor check proof.
Streaming function for producing the tensor check proof .
pub fn tensorcheck<F, E, SG, SB, SF1>(
    transcript: &mut Transcript,
    ck: CommitterKeyStream<E, SG>,
    base_polynomial: &SB,
    body_polynomials: (&SF1, &[F]),
    max_msm_buffer: usize,
) -> TensorcheckProof<E>
where
    F: Field,
    E: PairingEngine<Fr = F>,
    SG: Iterable,
    SG::Item: Borrow<E::G1Affine>,
    SB: Iterable,
    SB::Item: Borrow<E::Fr>,
    SF1: Iterable<Item = F>,
{
    let tensorcheck_challenges = strip_last(body_polynomials.1);
    let tensorcheck_foldings =
        FoldedPolynomialTree::new(body_polynomials.0, tensorcheck_challenges);
    let folded_polynomials_commitments = ck.commit_folding(&tensorcheck_foldings, max_msm_buffer);
    // add commitments to transcript
    folded_polynomials_commitments
        .iter()
        .for_each(|c| transcript.append_commitment(b"commitment", c));
    let eval_chal = transcript.get_challenge::<E::Fr>(b"evaluation-chal");
    let eval_points = [eval_chal.square(), eval_chal, -eval_chal];
    let folded_polynomials_evaluations = evaluate_folding(&tensorcheck_foldings, eval_points[1])
        .into_iter()
        .zip(evaluate_folding(&tensorcheck_foldings, eval_points[2]))
        .map(|(x, y)| [x, y])
        .collect::<Vec<_>>();
    let evaluations_w = [
        evaluate_be(base_polynomial.iter(), &eval_points[0]),
        evaluate_be(base_polynomial.iter(), &eval_points[1]),
        evaluate_be(base_polynomial.iter(), &eval_points[2]),
    ];
    evaluations_w
        .iter()
        .for_each(|e| transcript.append_scalar(b"eval", &e));
    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");
    let open_chal_len = body_polynomials.1.len() + 1;
    let open_chals = powers(open_chal, open_chal_len);
    let (_, proof_w) = ck.open_multi_points(base_polynomial, &eval_points, max_msm_buffer);
    let (_, proof) = ck.open_folding(
        tensorcheck_foldings,
        &eval_points,
        &open_chals[1..],
        max_msm_buffer,
    );
    let evaluation_proof = proof_w + proof;
    TensorcheckProof {
        folded_polynomials_commitments,
        folded_polynomials_evaluations,
        evaluation_proof,
        base_polynomials_evaluations: vec![evaluations_w],
    }
}
pub fn tensorcheck < F , E , SG , SB , SF1 > ( transcript : & mut Transcript , ck : CommitterKeyStream < E , SG > , base_polynomial : & SB , body_polynomials : ( & SF1 , & [ F ] ) , max_msm_buffer : usize , ) -> TensorcheckProof < E > where F : Field , E : PairingEngine < Fr = F > , SG : Iterable , SG :: Item : Borrow < E :: G1Affine > , SB : Iterable , SB :: Item : Borrow < E :: Fr > , SF1 : Iterable < Item = F > , { let tensorcheck_challenges = strip_last ( body_polynomials . 1 ) ; let tensorcheck_foldings = FoldedPolynomialTree :: new ( body_polynomials . 0 , tensorcheck_challenges ) ; let folded_polynomials_commitments = ck . commit_folding ( & tensorcheck_foldings , max_msm_buffer ) ; // add commitments to transcript folded_polynomials_commitments . iter ( ) . for_each ( | c | transcript . append_commitment ( b" " , c ) ) ; let eval_chal = transcript . get_challenge :: < E :: Fr > ( b" " ) ; let eval_points = [ eval_chal . square ( ) , eval_chal , - eval_chal ] ; let folded_polynomials_evaluations = evaluate_folding ( & tensorcheck_foldings , eval_points [ 1 ] ) . into_iter ( ) . zip ( evaluate_folding ( & tensorcheck_foldings , eval_points [ 2 ] ) ) . map ( | ( x , y ) | [ x , y ] ) . collect :: < Vec < _ > > ( ) ; let evaluations_w = [ evaluate_be ( base_polynomial . iter ( ) , & eval_points [ 0 ] ) , evaluate_be ( base_polynomial . iter ( ) , & eval_points [ 1 ] ) , evaluate_be ( base_polynomial . iter ( ) , & eval_points [ 2 ] ) , ] ; evaluations_w . iter ( ) . for_each ( | e | transcript . append_scalar ( b" " , & e ) ) ; folded_polynomials_evaluations . iter ( ) . flatten ( ) . for_each ( | e | transcript . append_scalar ( b" " , e ) ) ; let open_chal = transcript . get_challenge :: < E :: Fr > ( b" " ) ; let open_chal_len = body_polynomials . 1 . len ( ) + 1 ; let open_chals = powers ( open_chal , open_chal_len ) ; let ( _ , proof_w ) = ck . open_multi_points ( base_polynomial , & eval_points , max_msm_buffer ) ; let ( _ , proof ) = ck . open_folding ( tensorcheck_foldings , & eval_points , & open_chals [ 1 .. ] , max_msm_buffer , ) ; let evaluation_proof = proof_w + proof ; TensorcheckProof { folded_polynomials_commitments , folded_polynomials_evaluations , evaluation_proof , base_polynomials_evaluations : vec ! [ evaluations_w ] , } }
Streaming function for producing the tensor check proof.
Streaming function for producing the tensor check proof .
transcript
&mut Transcript
ck
CommitterKeyStream<E, SG>
base_polynomial
&SB
body_polynomials
(&SF1, &[F])
max_msm_buffer
usize