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: replace local prover by zkm recursion #61

Merged
merged 2 commits into from
Mar 14, 2025
Merged
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
2 changes: 2 additions & 0 deletions host-program/mem-alloc-vec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ edition = "2021"

[dependencies]
zkm-sdk = { path = "../../sdk", features = ["snark"] }
zkm-recursion = {git = "https://github.com/zkMIPS/zkm", branch = "main", default-features = false }

#tonic = "0.8.1"
tokio = { version = "1.21.0", features = ["macros", "rt-multi-thread", "signal"] }
log = { version = "0.4.14", default-features = false }
Expand Down
9 changes: 1 addition & 8 deletions host-program/mem-alloc-vec/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,7 @@ async fn main() -> Result<()> {

//excuting the setup_and_generate_sol_verifier
if prover_input.snark_setup {
match prover_client
.setup_and_generate_sol_verifier(
&client_config.zkm_prover_type,
&client_config.vk_path,
&prover_input,
)
.await
{
match zkm_recursion::groth16_setup(&client_config.vk_path) {
Ok(()) => log::info!("Succussfully setup_and_generate_sol_verifier."),
Err(e) => {
log::info!("Error during setup_and_generate_sol_verifier: {}", e);
Expand Down
2 changes: 2 additions & 0 deletions host-program/revme/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ edition = "2021"

[dependencies]
zkm-sdk = { path = "../../sdk", features = ["snark"] }
zkm-recursion = {git = "https://github.com/zkMIPS/zkm", branch = "main", default-features = false }

tokio = { version = "1.21.0", features = ["macros", "rt-multi-thread", "signal"] }
#ethers = "2.0.14"
log = { version = "0.4.14", default-features = false }
Expand Down
9 changes: 1 addition & 8 deletions host-program/revme/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,7 @@ async fn main() -> Result<()> {

//excuting the setup_and_generate_sol_verifier
if prover_input.snark_setup {
match prover_client
.setup_and_generate_sol_verifier(
&client_config.zkm_prover_type,
&client_config.vk_path,
&prover_input,
)
.await
{
match zkm_recursion::groth16_setup(&client_config.vk_path) {
Ok(()) => log::info!("Succussfully setup_and_generate_sol_verifier."),
Err(e) => {
log::info!("Error during setup_and_generate_sol_verifier: {}", e);
Expand Down
1 change: 1 addition & 0 deletions host-program/sha2-go/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition = "2021"
[dependencies]
zkm-sdk = { path = "../../sdk", features = ["snark"] }
bincode = "1.3.3"
zkm-recursion = {git = "https://github.com/zkMIPS/zkm", branch = "main", default-features = false }

tokio = { version = "1.21.0", features = ["macros", "rt-multi-thread", "signal"] }
#ethers = "2.0.14"
Expand Down
9 changes: 1 addition & 8 deletions host-program/sha2-go/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@ async fn main() -> Result<()> {
log::info!("new prover client,ok.");
//excuting the setup_and_generate_sol_verifier
if prover_input.snark_setup {
match prover_client
.setup_and_generate_sol_verifier(
&client_config.zkm_prover_type,
&client_config.vk_path,
&prover_input,
)
.await
{
match zkm_recursion::groth16_setup(&client_config.vk_path) {
Ok(()) => log::info!("Succussfully setup_and_generate_sol_verifier."),
Err(e) => {
log::info!("Error during setup_and_generate_sol_verifier: {}", e);
Expand Down
1 change: 1 addition & 0 deletions host-program/sha2-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"

[dependencies]
zkm-sdk = { path = "../../sdk", features = ["snark"] }
zkm-recursion = {git = "https://github.com/zkMIPS/zkm", branch = "main", default-features = false }
bincode = "1.3.3"
sha2 = { version = "0.10.8", default-features = false }

Expand Down
9 changes: 1 addition & 8 deletions host-program/sha2-rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@ async fn main() -> Result<()> {

//excuting the setup_and_generate_sol_verifier
if prover_input.snark_setup {
match prover_client
.setup_and_generate_sol_verifier(
&client_config.zkm_prover_type,
&client_config.vk_path,
&prover_input,
)
.await
{
match zkm_recursion::groth16_setup(&client_config.vk_path) {
Ok(()) => log::info!("Succussfully setup_and_generate_sol_verifier."),
Err(e) => {
log::info!("Error during setup_and_generate_sol_verifier: {}", e);
Expand Down
1 change: 1 addition & 0 deletions sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ async-trait = "0.1"

zkm-prover = { git = "https://github.com/zkMIPS/zkm", branch = "main", default-features = false }
zkm-emulator = { git = "https://github.com/zkMIPS/zkm", branch = "main", default-features = false }
zkm-recursion = {git = "https://github.com/zkMIPS/zkm", branch = "main", default-features = false }
plonky2 = { git = "https://github.com/zkMIPS/plonky2.git", branch = "zkm_dev" }
#starky = { git = "https://github.com/zkMIPS/plonky2.git", branch = "zkm_dev" }

Expand Down
21 changes: 10 additions & 11 deletions sdk/build.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
use std::path::PathBuf;
use std::process::Command;
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("cargo:rerun-if-changed=go");
let out_dir = std::env::var("OUT_DIR").unwrap();
let dest_path = PathBuf::from(&out_dir);
let lib_name = "zkmgnark";
let dest = dest_path.join(format!("lib{}.a", lib_name));
let status = Command::new("go")
.current_dir("src/local/libsnark")
.env("CGO_ENABLED", "1")
.args(["build", "-tags=debug", "-o", dest.to_str().unwrap(), "-buildmode=c-archive", "."])
.status()
.expect("Failed to build Go library");
if !status.success() {
panic!("Go build failed");
}
// let dest = dest_path.join(format!("lib{}.a", lib_name));
// let status = Command::new("go")
// .current_dir("src/local/libsnark")
// .env("CGO_ENABLED", "1")
// .args(["build", "-tags=debug", "-o", dest.to_str().unwrap(), "-buildmode=c-archive", "."])
// .status()
// .expect("Failed to build Go library");
// if !status.success() {
// panic!("Go build failed");
// }

if std::env::var_os("USE_LOCAL_PROVER").is_some() {
tonic_build::configure()
Expand Down
14 changes: 0 additions & 14 deletions sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,6 @@ impl ProverClient {
Self { prover: Box::new(NetworkProver::new(client_config).await.unwrap()) }
}

pub async fn setup_and_generate_sol_verifier(
&self,
zkm_prover: &str,
vk_path: &str,
prover_input: &ProverInput,
) -> anyhow::Result<()> {
if is_local_prover(zkm_prover) {
log::info!("Excuting the setup.");
self.prover.setup_and_generate_sol_verifier(vk_path, prover_input, None).await?;
}

Ok(())
}

pub fn process_proof_results(
&self,
prover_result: &ProverResult,
Expand Down
Loading
Loading