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

Relayer Utils #7

Closed
wants to merge 13 commits into from
Closed
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
48 changes: 13 additions & 35 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
# Logs
logs
*.log
Expand Down Expand Up @@ -38,7 +39,6 @@ bower_components
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
Expand All @@ -53,12 +53,6 @@ typings/
# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

Expand All @@ -75,18 +69,11 @@ typings/
# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
# next.js build output
.next

# Nuxt.js build / generate output
# nuxt.js build output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist
Expand All @@ -103,24 +90,15 @@ dist
# TernJS port file
.tern-port

# builds
build
dist

# circuit-specific powers of tau are ignored
*.ptau
# universal ptaus not ignored
!ptau/*
# temporary ptaus are ignored
tmp.ptau

# is this still a thing lol
.DS_Store

# ignore auto generated test circuits
circuits/test
ptau
# Build directories
dist/
build/

# ide
# Editor directories and files
.idea
.vscode
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "packages/rapidsnark"]
path = packages/rapidsnark
url = https://github.com/iden3/rapidsnark-old.git
65 changes: 18 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,30 @@
# Tx Auth Email Wallet
# Email Wallet Monorepo

This is a monorepo for the Email Wallet project, which includes several components:

## CLI Usage
- Circuits
- Utils
- Relayer
- Prover

```sh
npx circomkit compile <circuit_name>

# print circuit info if you want to
npx circomkit info <circuit_name>
```
## Components

3. Commence circuit-specific setup. Normally, this requires us to download a Phase-1 PTAU file and provide it's path; however, Circomkit can determine the required PTAU and download it automatically when using `bn128` curve, thanks to [Perpetual Powers of Tau](https://github.com/privacy-scaling-explorations/perpetualpowersoftau). In this case, `sudoku_9x9` circuit has 4617 constraints, so Circomkit will download `powersOfTau28_hez_final_13.ptau` (see [here](https://github.com/iden3/snarkjs#7-prepare-phase-2)).

```sh
npx circomkit setup <circuit_name>
### Circuits
Contains the zero-knowledge circuits used in the Email Wallet system.

# alternative: provide the PTAU yourself
npx circomkit setup <circuit_name> <path-to-ptau>
```
### Utils
Utility functions and helper modules for the project.

4. Prepare your input file under `./inputs/<circuit_name>/default.json`.
### Relayer
The relayer component of the Email Wallet system.

5. We are ready to create a proof!
### Prover
A fast prover implementation for generating zkSNARK proofs.

```sh
npx circomkit prove <circuit_name> default
```
## Getting Started

6. We can then verify our proof. You can try and modify the public input at `./build/<circuit_name>/default/public.json` and see if the proof verifies or not!
To build the prover, run the following command:

```sh
npx circomkit verify <circuit_name> default
```


## Configuration

Circomkit checks for `circomkit.json` to override it's default configurations. We could for example change the target version, prime field and the proof system by setting `circomkit.json` to be:

```json
{
"version": "2.1.2",
"protocol": "plonk",
"prime": "bls12381"
}
```

## Testing

You can use the following commands to test the circuits:

```sh
# test everything
yarn test

# test a specific circuit
yarn test -g <circuit-name>
yarn build:prover
```
8 changes: 8 additions & 0 deletions docker/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# add git-ignore syntax here of things you don't want copied into docker image

.git
*Dockerfile*
*docker-compose*
node_modules
.env
env
23 changes: 23 additions & 0 deletions docker/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# SMTP service
SMTP_PORT=8080
SMTP_INTERNAL_SERVER_HOST=0.0.0.0
SMTP_INTERNAL_SERVER_PORT=3000
SMTP_DOMAIN_NAME=smtp.gmail.com
SMTP_LOGIN_ID= # IMAP login id - usually your email address.
SMTP_LOGIN_PASSWORD= # IMAP password - usually your email password. (app password for gmail)
SMTP_MESSAGE_ID_DOMAIN=mail.gmail.com
SMPT_JSON_LOGGER=false

# Imap service - for receiving emails from users
IMAP_LOGIN_ID= # IMAP login id - usually your email address.
IMAP_DOMAIN_NAME=imap.gmail.com
IMAP_PORT=993
IMAP_LOGIN_PASSWORD="" # IMAP password - usually your email password.
IMAP_AUTH_TYPE=password
# OR
IMAP_CLIENT_ID= # IMAP client id
IMAP_CLIENT_SECRET= # IMAP client secret
IMAP_AUTH_URL= # IMAP auth url
IMAP_TOKEN_URL= # IMAP token url
IMAP_REDIRECT_URL= # IMAP redirect url
IMAP_JSON_LOGGER=false
1 change: 1 addition & 0 deletions docker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
24 changes: 24 additions & 0 deletions docker/Dockerfile.imap
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Use the official Rust image as the base image
FROM rust:1.73 AS builder

# Install necessary dependencies
RUN apt-get update && apt-get install -y \
git \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*

# Set the working directory in the container
WORKDIR /usr/src/relayer-imap

# Clone the repository
RUN git clone https://github.com/zkfriendly/relayer-imap.git .

# Build the application
RUN cargo build --release

# Expose the port the app runs on
EXPOSE 8081

# update PATH to include the target/release directory
ENV PATH="/usr/src/relayer-imap/target/release:${PATH}"
24 changes: 24 additions & 0 deletions docker/Dockerfile.smtp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Use the official Rust image as the base image
FROM rust:1.73 AS builder

# Install necessary dependencies
RUN apt-get update && apt-get install -y \
git \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*

# Set the working directory in the container
WORKDIR /usr/src/relayer-smtp

# Clone the repository
RUN git clone https://github.com/zkfriendly/relayer-smtp.git .

# Build the application
RUN cargo build --release

# Expose the port the app runs on
EXPOSE 8080

# update PATH to include the target/release directory
ENV PATH="/usr/src/relayer-smtp/target/release:${PATH}"
36 changes: 36 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
services:
smtp:
build:
context: .
dockerfile: Dockerfile.smtp
environment:
- SERVER_HOST=${SMTP_INTERNAL_SERVER_HOST}
- SERVER_PORT=${SMTP_INTERNAL_SERVER_PORT}
- SMTP_DOMAIN_NAME=${SMTP_DOMAIN_NAME}
- SMTP_LOGIN_ID=${SMTP_LOGIN_ID}
- SMTP_LOGIN_PASSWORD=${SMTP_LOGIN_PASSWORD}
- MESSAGE_ID_DOMAIN=${SMTP_MESSAGE_ID_DOMAIN}
- JSON_LOGGER=${SMPT_JSON_LOGGER}
ports:
- "${SMTP_PORT}:${SMTP_INTERNAL_SERVER_PORT}"
command: ["relayer-smtp"]
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:${SMTP_INTERNAL_SERVER_PORT}/api/ping"]
interval: 1m30s
timeout: 30s
retries: 5
start_period: 30s

# imap:
# build:
# context: .
# dockerfile: Dockerfile.imap
# environment:
# - RELAYER_ENDPOINT=http://host.docker.internal:${RELAYER_PORT}/prover/signAndSend
# - IMAP_LOGIN_ID=${IMAP_LOGIN_ID}
# - IMAP_LOGIN_PASSWORD=${IMAP_LOGIN_PASSWORD}
# - IMAP_DOMAIN_NAME=${IMAP_DOMAIN_NAME}
# - IMAP_PORT=${IMAP_PORT}
# - AUTH_TYPE=${IMAP_AUTH_TYPE}
# - JSON_LOGGER=${IMAP_JSON_LOGGER}
# command: ["cargo", "run"]
Loading