Skip to content

Commit

Permalink
Expose common proof_gen types and add testing method
Browse files Browse the repository at this point in the history
  • Loading branch information
Nashtare committed Mar 1, 2024
1 parent 29bc330 commit 065b8dd
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Change position of empty node encoding in RLP segment ([#62](https://github.com/0xPolygonZero/zk_evm/pull/62))
- Unify interpreter and prover witness generation ([#56](https://github.com/0xPolygonZero/zk_evm/pull/56))
- Add utility method for testing CPU execution ([#71](https://github.com/0xPolygonZero/zk_evm/pull/71))
- Expose common types and dummy proof method for testing ([#73](https://github.com/0xPolygonZero/zk_evm/pull/73))

## [0.1.0] - 2024-02-21
* Initial release.
26 changes: 25 additions & 1 deletion proof_gen/src/proof_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@
use std::sync::{atomic::AtomicBool, Arc};

use evm_arithmetization::{AllStark, StarkConfig};
use plonky2::util::timing::TimingTree;
use plonky2::{
gates::noop::NoopGate,
iop::witness::PartialWitness,
plonk::{circuit_builder::CircuitBuilder, circuit_data::CircuitConfig},
util::timing::TimingTree,
};
use trace_decoder::types::TxnProofGenIR;

use crate::{
proof_types::{AggregatableProof, GeneratedAggProof, GeneratedBlockProof, GeneratedTxnProof},
prover_state::ProverState,
types::{Config, Field, PlonkyProofIntern, EXTENSION_DEGREE},
};

/// A type alias for `Result<T, ProofGenError>`.
Expand Down Expand Up @@ -108,3 +114,21 @@ pub fn generate_block_proof(
intern: b_proof_intern,
})
}

/// Generates a dummy proof for a dummy circuit doing nothing.
/// This is useful for testing purposes only.
pub fn dummy_proof() -> ProofGenResult<PlonkyProofIntern> {
let mut builder = CircuitBuilder::<Field, EXTENSION_DEGREE>::new(CircuitConfig::default());
builder.add_gate(NoopGate, vec![]);
let circuit_data = builder.build::<_>();

let inputs = PartialWitness::new();

plonky2::plonk::prover::prove::<Field, Config, EXTENSION_DEGREE>(
&circuit_data.prover_only,
&circuit_data.common,
inputs,
&mut TimingTree::default(),
)
.map_err(|e| ProofGenError(e.to_string()))
}
18 changes: 13 additions & 5 deletions proof_gen/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,23 @@ use plonky2::{
plonk::{config::PoseidonGoldilocksConfig, proof::ProofWithPublicInputs},
};

/// The base field on which statements are being proven.
pub type Field = GoldilocksField;
/// The recursive circuit configuration to be used to shrink and aggregate
/// proofs.
pub type Config = PoseidonGoldilocksConfig;
/// The extension degree of the field used in the proof system.
pub const EXTENSION_DEGREE: usize = 2;

/// A type alias for proofs generated by the zkEVM.
pub type PlonkyProofIntern = ProofWithPublicInputs<GoldilocksField, PoseidonGoldilocksConfig, 2>;
pub type PlonkyProofIntern = ProofWithPublicInputs<Field, Config, EXTENSION_DEGREE>;

/// A type alias for the set of preprocessed circuits necessary to generate
/// succinct block proofs.
pub type AllRecursiveCircuits = evm_arithmetization::fixed_recursive_verifier::AllRecursiveCircuits<
GoldilocksField,
PoseidonGoldilocksConfig,
2,
Field,
Config,
EXTENSION_DEGREE,
>;

/// A type alias for the verifier data necessary to verify succinct block
Expand All @@ -23,4 +31,4 @@ pub type AllRecursiveCircuits = evm_arithmetization::fixed_recursive_verifier::A
/// [`VerifierData`] is much lighter, allowing anyone to verify block proofs,
/// regardless of the underlying hardware.
pub type VerifierData =
plonky2::plonk::circuit_data::VerifierCircuitData<GoldilocksField, PoseidonGoldilocksConfig, 2>;
plonky2::plonk::circuit_data::VerifierCircuitData<Field, Config, EXTENSION_DEGREE>;

0 comments on commit 065b8dd

Please sign in to comment.