pub fn prove_batch<'a>(
        transcript: &mut Transcript,
        mut provers: Vec<Box<dyn Prover<F> + 'a>>,
    ) -> Sumcheck<F> {
        let rounds = provers.iter().map(|p| p.rounds()).fold(0, usize::max);
        let mut messages = Vec::with_capacity(rounds);
        let mut challenges = Vec::with_capacity(rounds);

        let coefficients = (0..provers.len())
            .map(|_| transcript.get_challenge::<F>(b"batch-sumcheck"))
            .collect::<Vec<_>>();

        for _ in 0..rounds {
            // obtain the next message from each prover, if possible in parallel.
            let round_messages = cfg_iter_mut!(provers).map(|p| {
                p.next_message().unwrap_or_else(|| {
                    let final_foldings = p.final_foldings().expect(
                        "If next_message is None, we expect final foldings to be available",
                    );
                    RoundMsg(final_foldings[0] * final_foldings[1], F::zero())
                })
            });
            // compute the non-oracle messagein the sumcheck:
            let message = round_messages
                .zip(&coefficients) // take the combination of messages and coefficients
                .map(|(m, c)| m.mul(c)) // multiply them if there's an actual message
                .sum(); // finally, add them up.
            messages.push(message); // add the message sent to the transcript
            transcript.append_prover_message(b"evaluations", &message);
            // compute the challenge for the next round
            let challenge: F = transcript.get_challenge(b"challenge");
            challenges.push(challenge);
            // Extract current randomness and fold the polynomials.
            provers.iter_mut().for_each(|prover| prover.fold(challenge));
        }
        let final_foldings = provers
            .iter()
            .map(|p| {
                let final_folding = p.final_foldings().unwrap();
                transcript.append_scalar(b"final-folding-lhs", &final_folding[0]);
                transcript.append_scalar(b"final-folding-rhs", &final_folding[1]);
                final_folding
            })
            .collect::<Vec<_>>();
        Sumcheck {
            messages,
            challenges,
            rounds,
            final_foldings,
        }
    }
/// Prove function for a batch of scalar product instances.
Prove function for a batch of scalar product instances.
Prove function for a batch of scalar product instances .
pub fn prove_batch<'a>(
        transcript: &mut Transcript,
        mut provers: Vec<Box<dyn Prover<F> + 'a>>,
    ) -> Sumcheck<F> {
        let rounds = provers.iter().map(|p| p.rounds()).fold(0, usize::max);
        let mut messages = Vec::with_capacity(rounds);
        let mut challenges = Vec::with_capacity(rounds);
        let coefficients = (0..provers.len())
            .map(|_| transcript.get_challenge::<F>(b"batch-sumcheck"))
            .collect::<Vec<_>>();
        for _ in 0..rounds {
            // obtain the next message from each prover, if possible in parallel.
            let round_messages = cfg_iter_mut!(provers).map(|p| {
                p.next_message().unwrap_or_else(|| {
                    let final_foldings = p.final_foldings().expect(
                        "If next_message is None, we expect final foldings to be available",
                    );
                    RoundMsg(final_foldings[0] * final_foldings[1], F::zero())
                })
            });
            // compute the non-oracle messagein the sumcheck:
            let message = round_messages
                .zip(&coefficients) // take the combination of messages and coefficients
                .map(|(m, c)| m.mul(c)) // multiply them if there's an actual message
                .sum(); // finally, add them up.
            messages.push(message); // add the message sent to the transcript
            transcript.append_prover_message(b"evaluations", &message);
            // compute the challenge for the next round
            let challenge: F = transcript.get_challenge(b"challenge");
            challenges.push(challenge);
            // Extract current randomness and fold the polynomials.
            provers.iter_mut().for_each(|prover| prover.fold(challenge));
        }
        let final_foldings = provers
            .iter()
            .map(|p| {
                let final_folding = p.final_foldings().unwrap();
                transcript.append_scalar(b"final-folding-lhs", &final_folding[0]);
                transcript.append_scalar(b"final-folding-rhs", &final_folding[1]);
                final_folding
            })
            .collect::<Vec<_>>();
        Sumcheck {
            messages,
            challenges,
            rounds,
            final_foldings,
        }
    }
pub fn prove_batch < ' a > ( transcript : & mut Transcript , mut provers : Vec < Box < dyn Prover < F > + ' a > > , ) -> Sumcheck < F > { let rounds = provers . iter ( ) . map ( | p | p . rounds ( ) ) . fold ( 0 , usize :: max ) ; let mut messages = Vec :: with_capacity ( rounds ) ; let mut challenges = Vec :: with_capacity ( rounds ) ; let coefficients = ( 0 .. provers . len ( ) ) . map ( | _ | transcript . get_challenge :: < F > ( b" " ) ) . collect :: < Vec < _ > > ( ) ; for _ in 0 .. rounds { // obtain the next message from each prover, if possible in parallel. let round_messages = cfg_iter_mut ! ( provers ) . map ( | p | { p . next_message ( ) . unwrap_or_else ( | | { let final_foldings = p . final_foldings ( ) . expect ( " " , ) ; RoundMsg ( final_foldings [ 0 ] * final_foldings [ 1 ] , F :: zero ( ) ) } ) } ) ; // compute the non-oracle messagein the sumcheck: let message = round_messages . zip ( & coefficients ) // take the combination of messages and coefficients . map ( | ( m , c ) | m . mul ( c ) ) // multiply them if there's an actual message . sum ( ) ; // finally, add them up. messages . push ( message ) ; // add the message sent to the transcript transcript . append_prover_message ( b" " , & message ) ; // compute the challenge for the next round let challenge : F = transcript . get_challenge ( b" " ) ; challenges . push ( challenge ) ; // Extract current randomness and fold the polynomials. provers . iter_mut ( ) . for_each ( | prover | prover . fold ( challenge ) ) ; } let final_foldings = provers . iter ( ) . map ( | p | { let final_folding = p . final_foldings ( ) . unwrap ( ) ; transcript . append_scalar ( b" " , & final_folding [ 0 ] ) ; transcript . append_scalar ( b" " , & final_folding [ 1 ] ) ; final_folding } ) . collect :: < Vec < _ > > ( ) ; Sumcheck { messages , challenges , rounds , final_foldings , } }
Prove function for a batch of scalar product instances.
Prove function for a batch of scalar product instances .
transcript
&mut Transcript
provers
Vec<Box<dyn Prover<F> + 'a>>