/// Generate proof from any IOPProver and IOPVerifier with consistent
/// parameter and public input.
Generate proof from any IOPProver and IOPVerifier with consistent
parameter and public input.
Generate proof from any IOPProver and IOPVerifier with consistent parameter and public input .
pub fn generate<V, P, L, S>(
        sponge: S,
        public_input: &P::PublicInput,
        private_input: &P::PrivateInput,
        prover_parameter: &P::ProverParameter,
        ldt_params: &L::LDTParameters,
        hash_params: MTHashParameters<MT>,
    ) -> Result<Self, Error>
    where
        L: LDT<F>,
        P: IOPProver<F>,
        V: IOPVerifierForProver<S, F, P>,
        S: CryptographicSponge,
    {
        let verifier_parameter = prover_parameter.to_verifier_param();
        // create a BCS transcript
        let mut transcript = {
            Transcript::new(
                sponge,
                hash_params,
                L::codeword_domain(ldt_params),
                L::localization_param(ldt_params),
                iop_trace!("BCS Proof Generation"),
            )
        };
        let root_namespace = NameSpace::root(iop_trace!("BCS Proof Generation: Commit Phase"));
        // run prover code, using transcript to sample verifier message
        // This is not a subprotocol, so we use root namespace (/).
        P::prove(
            root_namespace,
            public_input,
            private_input,
            &mut transcript,
            prover_parameter,
        )?;
        // sanity check: pending message should be None
        debug_assert!(
            !transcript.is_pending_message_available(),
            "Sanity check failed: pending message not submitted."
        );
        // perform LDT to enforce degree bound on low-degree oracles
        let ldt_namespace = transcript.new_namespace(root_namespace, iop_trace!("LDT"));
        let codewords = transcript.bookkeeper.dump_all_prover_messages_in_order();
        L::prove(ldt_namespace, ldt_params, &mut transcript, &codewords)?;
        debug_assert!(
            !transcript.is_pending_message_available(),
            "Sanity check failed: pending message not submitted."
        );
        // extract things from main transcript
        let mut sponge = transcript.sponge;
        let mut transcript_messages = MessagesCollection::new(
            transcript.prover_message_oracles,
            transcript
                .registered_virtual_oracles
                .into_iter()
                .map(|v| Some(v.0))
                .collect(),
            transcript.verifier_messages,
            transcript.bookkeeper,
        );
        // run LDT verifier code to obtain all queries. We will use this query to
        // generate succinct oracles from message recording oracle.
        L::query_and_decide(
            ldt_namespace,
            ldt_params,
            &mut sponge,
            &codewords,
            &mut transcript_messages,
        )?;
        // run main verifier code to obtain all queries
        V::query_and_decide(
            NameSpace::root(iop_trace!("BCS Proof Generation: Query and Decision Phase")),
            &verifier_parameter,
            public_input,
            &mut sponge,
            &mut transcript_messages,
        )?;
        // convert oracles to succinct oracle
        let all_succinct_oracles: Vec<_> = transcript_messages
            .real_oracles
            .iter()
            .map(|x| x.get_succinct())
            .collect();
        let all_queries: Vec<_> = transcript_messages
            .real_oracles
            .iter()
            .map(|msg| msg.queried_coset_index.clone())
            .collect();
        let merkle_trees = transcript.merkle_tree_for_each_round;
        // generate all merkle tree paths
        debug_assert_eq!(merkle_trees.len(), all_queries.len());
        let all_mt_paths = all_queries
            .iter()
            .zip(merkle_trees.iter())
            .map(|(queries, mt)| {
                queries
                    .iter()
                    .map(|query| {
                        mt.as_ref()
                            .expect("this oracle contains query but has no merkle tree")
                            .generate_proof(*query)
                            .expect("fail to generate mt path")
                    })
                    .collect()
            })
            .collect();
        let all_mt_roots: Vec<_> = merkle_trees
            .iter()
            .map(|x| x.as_ref().map(|tree| tree.root()))
            .collect();
        Ok(BCSProof {
            prover_iop_messages_by_round: all_succinct_oracles,
            prover_messages_mt_root: all_mt_roots,
            prover_oracles_mt_path: all_mt_paths,
        })
    }
pub fn generate < V , P , L , S > ( sponge : S , public_input : & P :: PublicInput , private_input : & P :: PrivateInput , prover_parameter : & P :: ProverParameter , ldt_params : & L :: LDTParameters , hash_params : MTHashParameters < MT > , ) -> Result < Self , Error > where L : LDT < F > , P : IOPProver < F > , V : IOPVerifierForProver < S , F , P > , S : CryptographicSponge , { let verifier_parameter = prover_parameter . to_verifier_param ( ) ; // create a BCS transcript let mut transcript = { Transcript :: new ( sponge , hash_params , L :: codeword_domain ( ldt_params ) , L :: localization_param ( ldt_params ) , iop_trace ! ( " " ) , ) } ; let root_namespace = NameSpace :: root ( iop_trace ! ( " " ) ) ; // run prover code, using transcript to sample verifier message // This is not a subprotocol, so we use root namespace (/). P :: prove ( root_namespace , public_input , private_input , & mut transcript , prover_parameter , ) ? ; // sanity check: pending message should be None debug_assert ! ( transcript is_pending_message_available ( ) " " ) ; // perform LDT to enforce degree bound on low-degree oracles let ldt_namespace = transcript . new_namespace ( root_namespace , iop_trace ! ( " " ) ) ; let codewords = transcript . bookkeeper . dump_all_prover_messages_in_order ( ) ; L :: prove ( ldt_namespace , ldt_params , & mut transcript , & codewords ) ? ; debug_assert ! ( transcript is_pending_message_available ( ) " " ) ; // extract things from main transcript let mut sponge = transcript . sponge ; let mut transcript_messages = MessagesCollection :: new ( transcript . prover_message_oracles , transcript . registered_virtual_oracles . into_iter ( ) . map ( | v | Some ( v . 0 ) ) . collect ( ) , transcript . verifier_messages , transcript . bookkeeper , ) ; // run LDT verifier code to obtain all queries. We will use this query to // generate succinct oracles from message recording oracle. L :: query_and_decide ( ldt_namespace , ldt_params , & mut sponge , & codewords , & mut transcript_messages , ) ? ; // run main verifier code to obtain all queries V :: query_and_decide ( NameSpace :: root ( iop_trace ! ( " " ) ) , & verifier_parameter , public_input , & mut sponge , & mut transcript_messages , ) ? ; // convert oracles to succinct oracle let all_succinct_oracles : Vec < _ > = transcript_messages . real_oracles . iter ( ) . map ( | x | x . get_succinct ( ) ) . collect ( ) ; let all_queries : Vec < _ > = transcript_messages . real_oracles . iter ( ) . map ( | msg | msg . queried_coset_index . clone ( ) ) . collect ( ) ; let merkle_trees = transcript . merkle_tree_for_each_round ; // generate all merkle tree paths debug_assert_eq ! ( merkle_trees len ( ) all_queries len ( ) ) ; let all_mt_paths = all_queries . iter ( ) . zip ( merkle_trees . iter ( ) ) . map ( | ( queries , mt ) | { queries . iter ( ) . map ( | query | { mt . as_ref ( ) . expect ( " " ) . generate_proof ( * query ) . expect ( " " ) } ) . collect ( ) } ) . collect ( ) ; let all_mt_roots : Vec < _ > = merkle_trees . iter ( ) . map ( | x | x . as_ref ( ) . map ( | tree | tree . root ( ) ) ) . collect ( ) ; Ok ( BCSProof { prover_iop_messages_by_round : all_succinct_oracles , prover_messages_mt_root : all_mt_roots , prover_oracles_mt_path : all_mt_paths , } ) }
Generate proof from any IOPProver and IOPVerifier with consistent
parameter and public input.
Generate proof from any IOPProver and IOPVerifier with consistent parameter and public input .
sponge
S
public_input
&P::PublicInput
private_input
&P::PrivateInput
prover_parameter
&P::ProverParameter
ldt_params
&L::LDTParameters
hash_params
MTHashParameters<MT>