From 571a9e25bfb119ebf23c8d8c83eed19858609111 Mon Sep 17 00:00:00 2001 From: zkfriendly Date: Sat, 4 Jan 2025 13:32:25 +0100 Subject: [PATCH] feat: use gpu prover --- Cargo.lock | 52 ++++++++++++++++++++++++++++++---- packages/relayer/Cargo.toml | 2 +- packages/relayer/src/config.rs | 23 +++++++++++---- packages/relayer/src/prove.rs | 14 +++++---- 4 files changed, 73 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0bc0887..5dcc8de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1940,6 +1940,32 @@ version = "1.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403" +[[package]] +name = "halo2curves" +version = "0.7.0" +source = "git+https://github.com/privacy-scaling-explorations/halo2curves.git?rev=8771fe5a5d54fc03e74dbc8915db5dad3ab46a83#8771fe5a5d54fc03e74dbc8915db5dad3ab46a83" +dependencies = [ + "blake2", + "digest 0.10.7", + "ff", + "group", + "halo2derive 0.1.0 (git+https://github.com/privacy-scaling-explorations/halo2curves.git?rev=8771fe5a5d54fc03e74dbc8915db5dad3ab46a83)", + "lazy_static", + "num-bigint", + "num-integer", + "num-traits", + "pairing", + "pasta_curves", + "paste", + "rand", + "rand_core", + "rayon", + "sha2 0.10.8", + "static_assertions", + "subtle", + "unroll", +] + [[package]] name = "halo2curves" version = "0.7.0" @@ -1949,7 +1975,7 @@ dependencies = [ "digest 0.10.7", "ff", "group", - "halo2derive", + "halo2derive 0.1.0 (git+https://github.com/privacy-scaling-explorations/halo2curves.git)", "lazy_static", "num-bigint", "num-integer", @@ -1966,6 +1992,19 @@ dependencies = [ "unroll", ] +[[package]] +name = "halo2derive" +version = "0.1.0" +source = "git+https://github.com/privacy-scaling-explorations/halo2curves.git?rev=8771fe5a5d54fc03e74dbc8915db5dad3ab46a83#8771fe5a5d54fc03e74dbc8915db5dad3ab46a83" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "halo2derive" version = "0.1.0" @@ -3606,7 +3645,7 @@ version = "1.0.0" source = "git+https://github.com/zkemail/poseidon-rs.git#fe5ce2634c27326219d4faf75beb73b40a0beb7d" dependencies = [ "getrandom", - "halo2curves", + "halo2curves 0.7.0 (git+https://github.com/privacy-scaling-explorations/halo2curves.git)", "once_cell", "serde", "thiserror 1.0.69", @@ -3921,15 +3960,16 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "relayer-utils" -version = "0.4.2" -source = "git+https://github.com/zkemail/relayer-utils.git?branch=main#0663df1271beac13ec14c731ee1ce7ae4be54d16" +version = "0.4.60" +source = "git+https://github.com/zkemail/relayer-utils.git?branch=feat/gpu_prover#92e0db380d6340cd4b608acf5b4b87af099ef12a" dependencies = [ "anyhow", "base64 0.22.1", "cfdkim", + "console_error_panic_hook", "ethers", "file-rotate", - "halo2curves", + "halo2curves 0.7.0 (git+https://github.com/privacy-scaling-explorations/halo2curves.git?rev=8771fe5a5d54fc03e74dbc8915db5dad3ab46a83)", "hex", "hmac-sha256", "itertools 0.10.5", @@ -6342,7 +6382,7 @@ dependencies = [ [[package]] name = "zk-regex-apis" version = "2.3.1" -source = "git+https://github.com/zkemail/zk-regex.git#7002a2179e076449b84e3e7e8ba94e88d0a2dc2f" +source = "git+https://github.com/zkemail/zk-regex.git?branch=dimidumo/zk-802-consistent-casing-everywhere#5b357f2c7aa4643964534d88ebe5db3512048a71" dependencies = [ "fancy-regex", "itertools 0.13.0", diff --git a/packages/relayer/Cargo.toml b/packages/relayer/Cargo.toml index de22326..0dcfb7d 100644 --- a/packages/relayer/Cargo.toml +++ b/packages/relayer/Cargo.toml @@ -20,7 +20,7 @@ sqlx = { version = "0.8.2", features = [ bigdecimal = "0.3.1" tokio = { version = "1.40.0", features = ["full"] } tower-http = { version = "0.6.1", features = ["cors"] } -relayer-utils = { git = "https://github.com/zkemail/relayer-utils.git", branch = "main" } +relayer-utils = { git = "https://github.com/zkemail/relayer-utils.git", branch = "feat/gpu_prover" } slog = { version = "2.7.0", features = [ "max_level_trace", "release_max_level_warn", diff --git a/packages/relayer/src/config.rs b/packages/relayer/src/config.rs index c11aedb..f3945f1 100644 --- a/packages/relayer/src/config.rs +++ b/packages/relayer/src/config.rs @@ -14,10 +14,8 @@ pub struct Config { pub database_url: String, /// The URL for the SMTP server. pub smtp_url: String, - /// The URL for the prover service. - pub prover_url: String, - // /// The API key for Alchemy services. - // pub alchemy_api_key: String, + /// Configuration for the prover service. + pub prover: ProverConfig, /// Configuration for file paths. pub path: PathConfig, /// Configuration for ICP (Internet Computer Protocol). @@ -57,8 +55,21 @@ pub struct ChainConfig { pub rpc_url: String, /// The chain ID for the blockchain. pub chain_id: u32, - // /// The name used for Alchemy services. - // pub alchemy_name: String, +} + +#[derive(Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct ProverConfig { + /// The URL for the prover service. + pub url: String, + /// The blueprint ID for the prover. + pub blueprint_id: String, + /// The URL for downloading zkey files. + pub zkey_download_url: String, + /// The URL for downloading circuit CPP files. + pub circuit_cpp_download_url: String, + /// The API key for the prover. + pub api_key: String, } // Function to load the configuration from a JSON file diff --git a/packages/relayer/src/prove.rs b/packages/relayer/src/prove.rs index a44263d..9dd685a 100644 --- a/packages/relayer/src/prove.rs +++ b/packages/relayer/src/prove.rs @@ -1,7 +1,7 @@ use anyhow::Result; use relayer_utils::{ - generate_email_circuit_input, generate_proof, u256_to_bytes32, EmailCircuitParams, ParsedEmail, - LOG, + generate_email_circuit_input, generate_proof, generate_proof_gpu, u256_to_bytes32, + EmailCircuitParams, ParsedEmail, LOG, }; use slog::info; @@ -54,10 +54,14 @@ pub async fn generate_email_proof( .await?; // Generate the proof and public signals using the circuit input - let (proof, public_signals) = generate_proof( + let (proof, public_signals) = generate_proof_gpu( &circuit_input, - "email_auth", - &relayer_state.config.prover_url, + &relayer_state.config.prover.blueprint_id, + &uuid::Uuid::new_v4().to_string(), + &relayer_state.config.prover.zkey_download_url, + &relayer_state.config.prover.circuit_cpp_download_url, + &relayer_state.config.prover.api_key, + &relayer_state.config.prover.url, ) .await?;