Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: snark proof is already verified inside wrap_proof function #1903

Merged
merged 4 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ vk_setup_data_generator_server_fri = { path = "vk_setup_data_generator_server_fr
vlog = { path = "../core/lib/vlog" }
zk_evm = { git = "https://github.com/matter-labs/era-zk_evm.git", branch = "v1.4.1" }
zkevm_test_harness = { git = "https://github.com/matter-labs/era-zkevm_test_harness.git", branch = "v1.5.0" }
zkevm_test_harness_1_3_3 = { git = "https://github.com/matter-labs/era-zkevm_test_harness.git", branch = "v1.3.3", package = "zkevm_test_harness" }
zksync_basic_types = { path = "../core/lib/basic_types" }
zksync_config = { path = "../core/lib/config" }
zksync_dal = { path = "../core/lib/dal" }
Expand Down
1 change: 0 additions & 1 deletion prover/proof_fri_compressor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ zksync_queued_job_processor.workspace = true
vk_setup_data_generator_server_fri.workspace = true
vlog.workspace = true

zkevm_test_harness_1_3_3.workspace = true
circuit_sequencer_api.workspace = true
zkevm_test_harness.workspace = true

Expand Down
40 changes: 1 addition & 39 deletions prover/proof_fri_compressor/src/compressor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@ use circuit_sequencer_api::proof::FinalProof;
use prover_dal::{ConnectionPool, Prover, ProverDal};
use tokio::task::JoinHandle;
use zkevm_test_harness::proof_wrapper_utils::{wrap_proof, WrapperConfig};
use zkevm_test_harness_1_3_3::{
abstract_zksync_circuit::concrete_circuits::{
ZkSyncCircuit, ZkSyncProof, ZkSyncVerificationKey,
},
bellman::{
bn256::Bn256,
plonk::better_better_cs::{proof::Proof, setup::VerificationKey as SnarkVerificationKey},
},
witness::oracle::VmWitnessOracle,
};
use zksync_object_store::ObjectStore;
use zksync_prover_fri_types::{
circuit_definitions::{
Expand All @@ -38,7 +28,6 @@ pub struct ProofCompressor {
blob_store: Arc<dyn ObjectStore>,
pool: ConnectionPool<Prover>,
compression_mode: u8,
verify_wrapper_proof: bool,
max_attempts: u32,
protocol_version: ProtocolVersionId,
}
Expand All @@ -48,15 +37,13 @@ impl ProofCompressor {
blob_store: Arc<dyn ObjectStore>,
pool: ConnectionPool<Prover>,
compression_mode: u8,
verify_wrapper_proof: bool,
max_attempts: u32,
protocol_version: ProtocolVersionId,
) -> Self {
Self {
blob_store,
pool,
compression_mode,
verify_wrapper_proof,
max_attempts,
protocol_version,
}
Expand All @@ -65,7 +52,6 @@ impl ProofCompressor {
pub fn compress_proof(
proof: ZkSyncRecursionLayerProof,
compression_mode: u8,
verify_wrapper_proof: bool,
) -> anyhow::Result<FinalProof> {
let keystore = Keystore::default();
let scheduler_vk = keystore
Expand All @@ -81,29 +67,6 @@ impl ProofCompressor {
let serialized = bincode::serialize(&inner)
.expect("Failed to serialize proof with ZkSyncSnarkWrapperCircuit");

if verify_wrapper_proof {
// If we want to verify the proof, we have to deserialize it, with proper type.
// So that we can pass it into `from_proof_and_numeric_type` method below.
let proof: Proof<Bn256, ZkSyncCircuit<Bn256, VmWitnessOracle<Bn256>>> =
bincode::deserialize(&serialized)
.expect("Failed to deserialize proof with ZkSyncCircuit");
// We're fetching the key as String and deserializing it here
// as we don't want to include the old version of prover in the main libraries.
let existing_vk_serialized = keystore
.load_snark_verification_key()
.context("get_snark_vk()")?;
let existing_vk = serde_json::from_str::<
SnarkVerificationKey<Bn256, ZkSyncCircuit<Bn256, VmWitnessOracle<Bn256>>>,
>(&existing_vk_serialized)?;

let vk = ZkSyncVerificationKey::from_verification_key_and_numeric_type(0, existing_vk);
let scheduler_proof = ZkSyncProof::from_proof_and_numeric_type(0, proof.clone());
match vk.verify_proof(&scheduler_proof) {
true => tracing::info!("Compressed proof verified successfully"),
false => anyhow::bail!("Compressed proof verification failed "),
}
}

// For sending to L1, we can use the `FinalProof` type, that has a generic circuit inside, that is not used for serialization.
// So `FinalProof` and `Proof<Bn256, ZkSyncCircuit<Bn256, VmWitnessOracle<Bn256>>>` are compatible on serialization bytecode level.
let final_proof: FinalProof =
Expand Down Expand Up @@ -185,11 +148,10 @@ impl JobProcessor for ProofCompressor {
_started_at: Instant,
) -> JoinHandle<anyhow::Result<Self::JobArtifacts>> {
let compression_mode = self.compression_mode;
let verify_wrapper_proof = self.verify_wrapper_proof;
let block_number = *job_id;
tokio::task::spawn_blocking(move || {
let _span = tracing::info_span!("compress", %block_number).entered();
Self::compress_proof(job, compression_mode, verify_wrapper_proof)
Self::compress_proof(job, compression_mode)
})
}

Expand Down
1 change: 0 additions & 1 deletion prover/proof_fri_compressor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ async fn main() -> anyhow::Result<()> {
blob_store,
pool,
config.compression_mode,
config.verify_wrapper_proof,
config.max_attempts,
protocol_version,
);
Expand Down
Loading