Skip to content
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
1,129 changes: 39 additions & 1,090 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ snark-verifier-sdk = { version = "0.2.0", default-features = false, features = [
snark-verifier = { version = "0.2.0", default-features = false }
halo2curves-axiom = "0.7.0"

forge-fmt = "0.2.0"
# forge-fmt = "0.2.0"
cargo_metadata = "0.18"
alloy-sol-types = "0.8.25"
tracing = "0.1.40"
Expand Down
10 changes: 6 additions & 4 deletions crates/cli/src/commands/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ impl SetupCmd {
println!("Generating root verifier ASM...");
let root_verifier_asm = sdk.generate_root_verifier_asm();

println!("Generating verifier contract...");
let verifier = sdk.generate_halo2_verifier_solidity()?;
// _debug: forge_fmt
// println!("Generating verifier contract...");
// let verifier = sdk.generate_halo2_verifier_solidity()?;

println!("Writing stark proving key to file...");
write_object_to_file(&default_agg_stark_pk_path, sdk.agg_pk())?;
Expand All @@ -139,8 +140,9 @@ impl SetupCmd {
println!("Writing root verifier ASM to file...");
write(&default_asm_path, root_verifier_asm)?;

println!("Writing verifier contract to file...");
write_evm_halo2_verifier_to_folder(verifier, &default_evm_halo2_verifier_path)?;
// _debug: forge_fmt
// println!("Writing verifier contract to file...");
// write_evm_halo2_verifier_to_folder(verifier, &default_evm_halo2_verifier_path)?;
}
Ok(())
}
Expand Down
3 changes: 1 addition & 2 deletions crates/sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ snark-verifier = { workspace = true, optional = true }
snark-verifier-sdk = { workspace = true, optional = true }
tempfile.workspace = true
hex.workspace = true
forge-fmt = { workspace = true, optional = true }
# forge-fmt = { workspace = true, optional = true }
rrs-lib.workspace = true
num-bigint.workspace = true
cfg-if.workspace = true
Expand All @@ -75,7 +75,6 @@ evm-verify = [
"evm-prove",
"openvm-native-recursion/evm-verify",
"dep:alloy-sol-types",
"dep:forge-fmt",
]
metrics = [
"openvm-circuit/metrics",
Expand Down
6 changes: 4 additions & 2 deletions crates/sdk/examples/sdk_evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

// [!region evm_verification]
// 5. Generate the SNARK verifier smart contract
let verifier = sdk.generate_halo2_verifier_solidity()?;
// _debug: forge_fmt
// let verifier = sdk.generate_halo2_verifier_solidity()?;

// 6. Generate an EVM proof
// NOTE: this will do app_keygen, agg_keygen, halo2_keygen automatically if they have never been
Expand All @@ -60,7 +61,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let proof = sdk.prove_evm(elf, stdin)?;

// 7. Verify the EVM proof
Sdk::verify_evm_halo2_proof(&verifier, proof)?;
// _debug: forge_fmt
// Sdk::verify_evm_halo2_proof(&verifier, proof)?;
// [!endregion evm_verification]

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion crates/sdk/src/config/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ impl SdkVmConfig {
let io = config.io.map(|_| Rv32Io);
let keccak = config.keccak.map(|_| Keccak256);
let sha256 = config.sha256.map(|_| Sha256);
let native = config.native.map(|_| Native);
let native = config.native.map(|_| Native(false));
let castf = config.castf.map(|_| CastFExtension);
let rv32m = config.rv32m;
let bigint = config.bigint;
Expand Down
2 changes: 2 additions & 0 deletions crates/sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@ where
Ok(())
}

/* _debug: forge_fmt
#[cfg(feature = "evm-verify")]
pub fn generate_halo2_verifier_solidity(&self) -> Result<types::EvmHalo2Verifier, SdkError> {
use std::{
Expand Down Expand Up @@ -1036,6 +1037,7 @@ where
};
Ok(evm_verifier)
}
*/

#[cfg(feature = "evm-verify")]
/// Uses the `verify(..)` interface of the `OpenVmHalo2Verifier` contract.
Expand Down
2 changes: 2 additions & 0 deletions crates/sdk/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ fn test_static_verifier_custom_pv_handler() -> eyre::Result<()> {
Ok(())
}

/* _debug: forge_fmt
#[cfg(feature = "evm-verify")]
#[test]
fn test_e2e_proof_generation_and_verification_with_pvs() -> eyre::Result<()> {
Expand All @@ -431,6 +432,7 @@ fn test_e2e_proof_generation_and_verification_with_pvs() -> eyre::Result<()> {
Sdk::verify_evm_halo2_proof(&evm_verifier, evm_proof)?;
Ok(())
}
*/

#[test]
fn test_sdk_guest_build_and_transpile() -> eyre::Result<()> {
Expand Down
32 changes: 19 additions & 13 deletions extensions/native/circuit/src/extension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ cfg_if::cfg_if! {
// ============ VmExtension Implementations ============

#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize)]
pub struct Native;
pub struct Native(pub bool); // Encloses an indicator for whether NativeSumcheckAIR is present

#[derive(Clone, From, AnyEnum, Executor, MeteredExecutor, PreflightExecutor)]
pub enum NativeExecutor<F: Field> {
Expand Down Expand Up @@ -175,12 +175,14 @@ impl<F: PrimeField32> VmExecutionExtension<F> for Native {
],
)?;

let tower_verify = NativeSumcheckExecutor::new();
inventory.add_executor(
tower_verify,
[SumcheckOpcode::SUMCHECK_LAYER_EVAL.global_opcode()],
)?;

if self.0 {
let tower_verify = NativeSumcheckExecutor::new();
inventory.add_executor(
tower_verify,
[SumcheckOpcode::SUMCHECK_LAYER_EVAL.global_opcode()],
)?;
}

inventory.add_phantom_sub_executor(
NativeHintInputSubEx,
PhantomDiscriminant(NativePhantom::HintInput as u16),
Expand Down Expand Up @@ -274,9 +276,11 @@ where
);
inventory.add_air(verify_batch);

let tower_evaluate = NativeSumcheckAir::new(exec_bridge, memory_bridge);
inventory.add_air(tower_evaluate);

if self.0 {
let tower_evaluate = NativeSumcheckAir::new(exec_bridge, memory_bridge);
inventory.add_air(tower_evaluate);
}

Ok(())
}
}
Expand All @@ -293,7 +297,7 @@ where
{
fn extend_prover(
&self,
_: &Native,
ext_config: &Native,
inventory: &mut ChipInventory<SC, RA, CpuBackend<SC>>,
) -> Result<(), ChipInventoryError> {
let range_checker = inventory.range_checker()?.clone();
Expand Down Expand Up @@ -357,8 +361,10 @@ where
);
inventory.add_executor_chip(poseidon2);

let tower_verify = NativeSumcheckChip::new(NativeSumcheckFiller::new(), mem_helper.clone());
inventory.add_executor_chip(tower_verify);
if ext_config.0 {
let tower_verify = NativeSumcheckChip::new(NativeSumcheckFiller::new(), mem_helper.clone());
inventory.add_executor_chip(tower_verify);
}

Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions extensions/native/circuit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ mod loadstore;
mod poseidon2;
mod sumcheck;

mod extension;
pub mod extension;
pub use extension::*;
pub use field_extension::EXT_DEG;

Expand Down Expand Up @@ -173,7 +173,7 @@ impl Default for Rv32WithKernelsConfig {
rv32i: Rv32I,
rv32m: Rv32M::default(),
io: Rv32Io,
native: Native,
native: Native(false),
castf: CastFExtension,
}
}
Expand Down
8 changes: 4 additions & 4 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "1.86.0"
# To use the "tco" feature, switch to Rust nightly:
# channel = "nightly-2025-08-19"
components = ["clippy", "rustfmt"]
channel = "nightly-2025-11-20"
targets = ["riscv32im-unknown-none-elf"]
# We need the sources for build-std.
components = ["rust-src", "clippy", "rustfmt"]
Loading