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

Zkfriendly/zk 1053 swap modal prover in email tx builder with gpu prover #102

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
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.

11 changes: 11 additions & 0 deletions packages/circuits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ We provide one main circuit as follows.
#### `email_auth.circom`
A circuit to verify that a message in the subject is authorized by a user of an account salt, derived from an email address in the From field and a random field value called account code.

The circuit has the following blueprint ID and download URLs for the proving key and witness generator:
```json
{
"blueprintId": "7f3c3bc2-7c5d-4682-8d7f-f3d2f9046722",
"zkeyDownloadUrl": "https://storage.googleapis.com/circom-ether-email-auth/v2.0.2-dev/circuit_zkey.zip",
"circuitCppDownloadUrl": "https://storage.googleapis.com/circom-ether-email-auth/v2.0.2-dev/circuit.zip"
}
```

It takes as input the following data:
1. a padded email header `padded_header`.
It takes as input the following data:
1. a padded email header `padded_header`.
2. the bytes of the padded email header `padded_header_len`.
Expand Down
9 changes: 7 additions & 2 deletions packages/relayer/config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
"port": 8000,
"databaseUrl": "postgres://relayer:relayer_password@db:5432/relayer",
"smtpUrl": "http://smtp_server_1:3000",
"proverUrl": "https://zkemail--email-auth-prover-v1-5-4-flask-app.modal.run",
"alchemyApiKey": "",
"prover": {
"url": "https://prover.zk.email/api/prove",
"apiKey": "",
"blueprintId": "7f3c3bc2-7c5d-4682-8d7f-f3d2f9046722",
"zkeyDownloadUrl": "https://storage.googleapis.com/circom-ether-email-auth/v2.0.2-dev/circuit_zkey.zip",
"circuitCppDownloadUrl": "https://storage.googleapis.com/circom-ether-email-auth/v2.0.2-dev/circuit.zip"
},
"path": {
"pem": "./.ic.pem",
"emailTemplates": "./email_templates"
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_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
Loading