pub fn verify_tx(tx: &Tx, bp_gens: &BulletproofGens) -> Result<VerifiedTx, VMError> {
        let mut r1cs_transcript = Transcript::new(b"ZkVM.r1cs");
        let cs = r1cs::Verifier::new(&mut r1cs_transcript);

        let mut verifier = Verifier {
            signtx_keys: Vec::new(),
            deferred_operations: Vec::new(),
            cs: cs,
        };

        let vm = VM::new(
            tx.header,
            VerifierRun::new(tx.program.clone()),
            &mut verifier,
        );

        let (txid, txlog) = vm.run()?;

        // Verify the signatures over txid
        let mut signtx_transcript = Transcript::new(b"ZkVM.signtx");
        signtx_transcript.commit_bytes(b"txid", &txid.0);

        if verifier.signtx_keys.len() != 0 {
            verifier.deferred_operations.push(
                // TODO: use MuSig multi-message API, signing contract
                // IDs in addition to TxID for each key.
                tx.signature
                    .verify(
                        &mut signtx_transcript,
                        Multikey::new(verifier.signtx_keys)
                            .map_err(|_| VMError::KeyAggregationFailed)?
                            .aggregated_key(),
                    )
                    .into(),
            );
        }

        // Verify all deferred crypto operations.
        PointOp::verify_batch(&verifier.deferred_operations[..])?;

        // Verify the R1CS proof

        // TBD: provide is as a precomputed object to avoid
        // creating secondary point per each tx verification
        let pc_gens = PedersenGens::default();

        verifier
            .cs
            .verify(&tx.proof, &pc_gens, bp_gens)
            .map_err(|_| VMError::InvalidR1CSProof)?;

        Ok(VerifiedTx {
            header: tx.header,
            id: txid,
            log: txlog,
        })
    }
/// Verifies the `Tx` object by executing the VM and returns the `VerifiedTx`.
/// Returns an error if the program is malformed or any of the proofs are not valid.
Verifies the `Tx` object by executing the VM and returns the `VerifiedTx`.
Returns an error if the program is malformed or any of the proofs are not valid.
Verifies the ` Tx ` object by executing the VM and returns the ` VerifiedTx ` . Returns an error if the program is malformed or any of the proofs are not valid .
pub fn verify_tx(tx: &Tx, bp_gens: &BulletproofGens) -> Result<VerifiedTx, VMError> {
        let mut r1cs_transcript = Transcript::new(b"ZkVM.r1cs");
        let cs = r1cs::Verifier::new(&mut r1cs_transcript);
        let mut verifier = Verifier {
            signtx_keys: Vec::new(),
            deferred_operations: Vec::new(),
            cs: cs,
        };
        let vm = VM::new(
            tx.header,
            VerifierRun::new(tx.program.clone()),
            &mut verifier,
        );
        let (txid, txlog) = vm.run()?;
        // Verify the signatures over txid
        let mut signtx_transcript = Transcript::new(b"ZkVM.signtx");
        signtx_transcript.commit_bytes(b"txid", &txid.0);
        if verifier.signtx_keys.len() != 0 {
            verifier.deferred_operations.push(
                // TODO: use MuSig multi-message API, signing contract
                // IDs in addition to TxID for each key.
                tx.signature
                    .verify(
                        &mut signtx_transcript,
                        Multikey::new(verifier.signtx_keys)
                            .map_err(|_| VMError::KeyAggregationFailed)?
                            .aggregated_key(),
                    )
                    .into(),
            );
        }
        // Verify all deferred crypto operations.
        PointOp::verify_batch(&verifier.deferred_operations[..])?;
        // Verify the R1CS proof
        // TBD: provide is as a precomputed object to avoid
        // creating secondary point per each tx verification
        let pc_gens = PedersenGens::default();
        verifier
            .cs
            .verify(&tx.proof, &pc_gens, bp_gens)
            .map_err(|_| VMError::InvalidR1CSProof)?;
        Ok(VerifiedTx {
            header: tx.header,
            id: txid,
            log: txlog,
        })
    }
pub fn verify_tx ( tx : & Tx , bp_gens : & BulletproofGens ) -> Result < VerifiedTx , VMError > { let mut r1cs_transcript = Transcript :: new ( b" " ) ; let cs = r1cs :: Verifier :: new ( & mut r1cs_transcript ) ; let mut verifier = Verifier { signtx_keys : Vec :: new ( ) , deferred_operations : Vec :: new ( ) , cs : cs , } ; let vm = VM :: new ( tx . header , VerifierRun :: new ( tx . program . clone ( ) ) , & mut verifier , ) ; let ( txid , txlog ) = vm . run ( ) ? ; // Verify the signatures over txid let mut signtx_transcript = Transcript :: new ( b" " ) ; signtx_transcript . commit_bytes ( b" " , & txid . 0 ) ; if verifier . signtx_keys . len ( ) != 0 { verifier . deferred_operations . push ( // TODO: use MuSig multi-message API, signing contract // IDs in addition to TxID for each key. tx . signature . verify ( & mut signtx_transcript , Multikey :: new ( verifier . signtx_keys ) . map_err ( | _ | VMError :: KeyAggregationFailed ) ? . aggregated_key ( ) , ) . into ( ) , ) ; } // Verify all deferred crypto operations. PointOp :: verify_batch ( & verifier . deferred_operations [ .. ] ) ? ; // Verify the R1CS proof // TBD: provide is as a precomputed object to avoid // creating secondary point per each tx verification let pc_gens = PedersenGens :: default ( ) ; verifier . cs . verify ( & tx . proof , & pc_gens , bp_gens ) . map_err ( | _ | VMError :: InvalidR1CSProof ) ? ; Ok ( VerifiedTx { header : tx . header , id : txid , log : txlog , } ) }
Verifies the `Tx` object by executing the VM and returns the `VerifiedTx`.
Verifies the ` Tx ` object by executing the VM and returns the ` VerifiedTx ` .
tx
&Tx
bp_gens
&BulletproofGens
tx
&Tx
bp_gens
&BulletproofGens