Skip to content

Commit

Permalink
feat: use gpu prover
Browse files Browse the repository at this point in the history
  • Loading branch information
zkfriendly committed Jan 4, 2025
1 parent b67d9d2 commit 571a9e2
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 18 deletions.
52 changes: 46 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
23 changes: 17 additions & 6 deletions packages/relayer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions packages/relayer/src/prove.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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?;

Expand Down

0 comments on commit 571a9e2

Please sign in to comment.