Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

naive snark circuit and pow bits for compression wrapper #179

Open
wants to merge 1 commit into
base: v1.5.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ type R = Poseidon2Goldilocks;
type EXT = GoldilocksExt2;
type H = GoldilocksPoseidon2Sponge<AbsorptionModeOverwrite>;

pub type CompressionPoWForWrapper =
Poseidon2Sponge<Bn256, F, AbsorptionModeReplacement<Fr>, 2, 3>;
pub type CompressionTreeHasherForWrapper =
Poseidon2Sponge<Bn256, F, AbsorptionModeReplacement<Fr>, 2, 3>;
pub type CompressionTranscriptForWrapper =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl ProofCompressionFunction for CompressionMode5ForWrapper {
type PreviousLayerPoW = NoPow;

// no PoW on this step too
type ThisLayerPoW = NoPow;
type ThisLayerPoW = CompressionPoWForWrapper;
type ThisLayerHasher = CompressionTreeHasherForWrapper;
type ThisLayerTranscript = CompressionTranscriptForWrapper;

Expand Down Expand Up @@ -100,7 +100,7 @@ impl ProofCompressionFunction for CompressionMode5ForWrapper {
merkle_tree_cap_size: 8,
fri_folding_schedule: None,
security_level: crate::L1_SECURITY_BITS,
pow_bits: 0,
pow_bits: 8,
}
}

Expand Down
19 changes: 14 additions & 5 deletions circuit_definitions/src/circuit_definitions/aux_layer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use snark_wrapper::boojum::config::CSConfig;
use snark_wrapper::boojum::dag::CircuitResolver;
use snark_wrapper::boojum::dag::StCircuitResolver;
use snark_wrapper::verifier::WrapperCircuitWidth3NoLookupNoCustomGate;

Check failure on line 19 in circuit_definitions/src/circuit_definitions/aux_layer/mod.rs

View workflow job for this annotation

GitHub Actions / cargo build

unresolved import `snark_wrapper::verifier::WrapperCircuitWidth3NoLookupNoCustomGate`

use crate::ProofConfig;

Expand Down Expand Up @@ -422,19 +423,19 @@
use crate::boojum::cs::traits::circuit::CircuitBuilder;
match &self {
Self::CompressionMode1Circuit(..) => {
<CompressionMode1Circuit as CircuitBuilder<GoldilocksField>>::geometry()
<CompressionMode1ForWrapperCircuit as CircuitBuilder<GoldilocksField>>::geometry()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may break existing functionality, I do not remember the path of how current scheduler proof is wrapper (most likely 1 FRI based proof to switch to BN254 hasher, and then PLONK proof), so such code path may be used and will break.

In general, would be nice to have comment on what's a difference between compression and compression for wrapper, especially at initial steps, as only one step should swap hasher

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, 'compression for wrapper' refers to using a BN-compatible hasher for both the transcript and the Merkle tree as it is the last step before EVM verification. Additionally, this is a circuit that verifies the proof of the previous ‘compression’ step. Therefore, it should return the geometry of 'CompressionMode1ForWrapperCircuit' for the constraint system, not 'CompressionMode1Circuit'.

}
Self::CompressionMode2Circuit(..) => {
<CompressionMode2Circuit as CircuitBuilder<GoldilocksField>>::geometry()
<CompressionMode2ForWrapperCircuit as CircuitBuilder<GoldilocksField>>::geometry()
}
Self::CompressionMode3Circuit(..) => {
<CompressionMode3Circuit as CircuitBuilder<GoldilocksField>>::geometry()
<CompressionMode3ForWrapperCircuit as CircuitBuilder<GoldilocksField>>::geometry()
}
Self::CompressionMode4Circuit(..) => {
<CompressionMode4Circuit as CircuitBuilder<GoldilocksField>>::geometry()
<CompressionMode4ForWrapperCircuit as CircuitBuilder<GoldilocksField>>::geometry()
}
Self::CompressionMode5Circuit(..) => {
<CompressionMode5Circuit as CircuitBuilder<GoldilocksField>>::geometry()
<CompressionMode5ForWrapperCircuit as CircuitBuilder<GoldilocksField>>::geometry()
}
}
}
Expand Down Expand Up @@ -657,6 +658,14 @@
ZkSyncCompressionWrapper,
>;

pub type ZkSyncSnarkWrapperCircuitNoLookupCustomGate = WrapperCircuitWidth3NoLookupNoCustomGate<
Bn256,
Poseidon2Sponge<Bn256, GoldilocksField, AbsorptionModeReplacement<Fr>, 2, 3>,
CircuitPoseidon2Sponge<Bn256, 2, 3, 3, true>,
CircuitPoseidon2Transcript<Bn256, 2, 3, 3, true>,
ZkSyncCompressionWrapper,
>;

use std::sync::Arc;
pub type ZkSyncSnarkWrapperProof =
ZkSyncCompressionLayerStorage<SnarkProof<Bn256, ZkSyncSnarkWrapperCircuit>>;
Expand Down
Loading