Skip to content

Commit

Permalink
Feat/docs (#15)
Browse files Browse the repository at this point in the history
* Reflect the latest changes on the main branch to the audit branch. (#7)

* Change modal server name.

* Add test to invitation code.

* Update zk-regex versions.

* update readme.

* Update modal server version.

* Fix typo.

* Fix contract unit tests.

* Fix Dockerfile in prover.

* feat: Add Relayer (#3)

* Add ECDSAOwnedDKIMRegistry.

* Update dev-setup.ts that generates Groth16Verifier.sol.

* Implement verifyEmailProof function.

* [WIP] Add implementations regarding authEmail function till step 7.

* Add isValidSignature function.

* Add EmailAccountRecovery.

* Move usedNullifiers from Verifier to EmailAuth.

* Tweak variable name.

* Update correct timestamp validation condition.

* Update isValidSignature function.

* Add unit test functions.

* Add testAuthEmail.

* Remove comment.

* Delete unused mock directory.

* Add testIsValidSignature.

* Format solidity files.

* Add deploy script.

* Modify ECSDSAOwnedDKIMRegistry to be independent of the chain id.

* Refactor EmailAuth contracts.

* Refactor EmailAccountRecovery.

* Add simple wallet to be recovered with emails.

* Fix EmailAuth.t.sol.

* Add DeploymentHelper.

* Add create SimpleWallet instance in setUp function.

* Add test EmailAccountRecovery.

* Fix EmailAccountRecovery.t.sol.

* Fix parameter decoding in recoverWallet method.

* Rename recoverWallet to processRecovery and add completeRecovery.

* Add recipient's email address commitment to the circuit.

* Add script to generate circuit inputs.

* Add prover.

* Add relayer.

* Update utils and relayer.

* Fix database.

* Remove unused code.

* Update database and web_server

* Fix config.rs

* Add ECDSAOwnedDKIMRegistry.

* Implement verifyEmailProof function.

* [WIP] Add implementations regarding authEmail function till step 7.

* Add isValidSignature function.

* Add EmailAccountRecovery.

* Move usedNullifiers from Verifier to EmailAuth.

* Tweak variable name.

* Update correct timestamp validation condition.

* Update isValidSignature function.

* Add unit test functions.

* Add testAuthEmail.

* Remove comment.

* Delete unused mock directory.

* Add testIsValidSignature.

* Format solidity files.

* Add deploy script.

* Modify ECSDSAOwnedDKIMRegistry to be independent of the chain id.

* Refactor EmailAuth contracts.

* Refactor EmailAccountRecovery.

* Add simple wallet to be recovered with emails.

* Fix EmailAuth.t.sol.

* Add DeploymentHelper.

* Add create SimpleWallet instance in setUp function.

* Add test EmailAccountRecovery.

* Fix EmailAccountRecovery.t.sol.

* Fix parameter decoding in recoverWallet method.

* Rename recoverWallet to processRecovery and add completeRecovery.

* Add recipient's email address commitment to the circuit.

* Add relayer.

* Update deployment helper.

* Fix unit testing

* Create Integration.t.sol.

* Add integration test for acceptance.

* Add integration test for recovery.

* Update README.md

* Call handleAcceptance and handleRecovery.

* Add require conditions and check the simpleWallet owner change.

* Add blank line.

* Fix database.

* Remove unused code.

* Update database and web_server

* Fix config.rs

* feat: relayer init

* feat: basic changes

* feat: changes

* feat: partial accept api

* feat: rebase

* feat: fixes

* feat: finish accept api before handling email

* feat: handle email stub

* feat: clean up

* feat: add all apis

* chore: refactor

* feat: add email templates

* feat: handle email

* Fix contract deployment scripts.

* Add github workflow.

* Add ETHERSCAN_API_KEY to env.sample.

* Add unit test functions.

* Add deploy script.

* Refactor EmailAuth contracts.

* feat: rebase

* feat: fixes

* Fix modal server name.

* feat: fixes

* feat: fixes

* Fix typo of EmailAccountRecoery.t.sol.

* feat: complete flow

* feat: fixes and refactoring

* chore: update .env.example

* Update utils package.

* feat: fixes

* feat: add k8s manifests

(cherry picked from commit 6f154f5)

* chore: fix Dockerfile

* Update the version of zk-regex-utils

---------

Co-authored-by: wshino <wshinohara@gmail.com>
Co-authored-by: SoraSuegami <suegamisora@gmail.com>

* Update OpenZeppelin libraries  (#5)

* Update @zk-email/contracts ^4.1.0 -> ^6.0.0.
Update @OpenZeppelin ^4.9.2 -> ^5.0.0.

* Regenerate verifier contract.

* Update integration test contract with regenerate eml files.

* Remove uniswap dependencies.

* Remove account abstraction dependency.

* Update the link for build_integration in google drive.

* forge install: forge-std

v1.8.1

* Re-generate yarn.lock.

* chore: update k8s manifests

(cherry picked from commit 72783078e6170f93665e5b6012d7ddd765fb44f9)

* Fix DeploySimpleWallet script to add initial owner.

* fix DeploySimpleWallet about init owner.

* Fix Groth16Verifier.

* Feat/unit testing for contracts (#6)

* Add configureTimelockPeriod to SimpleWallet.

---------

Co-authored-by: Aditya Bisht <44467788+Bisht13@users.noreply.github.com>
Co-authored-by: wshino <wshinohara@gmail.com>
Co-authored-by: Aditya Bisht <adityabisht64@gmail.com>

* Add more docs.

* Add Security Notes.

* Add Application.

* Add UX of the account recovery.

* Fix mistakes in README

* small modifications in README

* small modification to README

* Add remaining subsections.

* Write Integration to your Wallet.

* Fix mistakes.

* Add fronend description.

* Update specs.

* Complete the contracts spec.

* Add README to relayer.

* Add how to setup Relayer.

---------

Co-authored-by: Aditya Bisht <44467788+Bisht13@users.noreply.github.com>
Co-authored-by: wshino <wshinohara@gmail.com>
Co-authored-by: Aditya Bisht <adityabisht64@gmail.com>
  • Loading branch information
4 people authored Apr 29, 2024
1 parent 212dc45 commit 245b8d6
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions packages/relayer/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,84 @@
This is a Relayer server implementation in Rust for email-based account recovery.

## How to Run the Relayer
You can run the relayer either on your local environments or cloud instances (we are using GCP).
### Local
1. Clone the repo, https://github.com/zkemail/ether-email-auth.
2. Install dependencies.
1. `cd ether-email-auth` and run `yarn`.
3. If you have not deployed common contracts, build contract artifacts and deploy required contracts.
1. `cd packages/contracts` and run `forge build`.
2. Set the env file in `packages/contracts/.env`, an example env file is as follows,

```jsx
LOCALHOST_RPC_URL=http://127.0.0.1:8545
SEPOLIA_RPC_URL=https://sepolia.base.org
MAINNET_RPC_URL=https://mainnet.base.org

PRIVATE_KEY=""
CHAIN_ID=84532
RPC_URL="https://sepolia.base.org"
SIGNER=0x69bec2dd161d6bbcc91ec32aa44d9333ebc864c0 # Signer for the dkim oracle on IC
ETHERSCAN_API_KEY=
# CHAIN_NAME="base_sepolia"
```
3. Run `forge script script/DeployCommons.s.sol:Deploy -vvvv --rpc-url $RPC_URL --broadcast` to get `ECDSAOwnedDKIMRegistry`, `Verifier`, `EmailAuth implementation` and `SimpleWallet implementation`.
4. Install PostgreSQL and create a database.
1. `psql -U <admin_user> -d postgres` to login to administrative PostgreSQL user. Replace **`<admin_user>`** with the administrative PostgreSQL user (commonly **`postgres`**).
2. Create a new user, `CREATE USER my_new_user WITH PASSWORD 'my_secure_password';`, `ALTER USER my_new_user CREATEDB;`.
3. Exit `psql` and now create a new database, `psql -U new_user -d postgres` followed by `CREATE DATABASE my_new_database;`.
5. Run the prover.
1. `cd packages/prover` and `python local.py`, let this run async.
6. Run the relayer.
1. `cd packages/relayer`.
2. Set the env file, an example env file is as follows,
```jsx
EMAIL_ACCOUNT_RECOVERY_VERSION_ID=1 # Address of the deployed wallet contract.
PRIVATE_KEY= # Private key for Relayer's account.
CHAIN_RPC_PROVIDER=https://sepolia.base.org
CHAIN_RPC_EXPLORER=https://sepolia.basescan.org
CHAIN_ID=84532 # Chain ID of the testnet.
# IMAP + SMTP (Settings will be provided by your email provider)
IMAP_DOMAIN_NAME=imap.gmail.com
IMAP_PORT=993
AUTH_TYPE=password
SMTP_DOMAIN_NAME=smtp.gmail.com
LOGIN_ID= # IMAP login id - usually your email address.
LOGIN_PASSWORD="" # IMAP password - usually your email password.
PROVER_ADDRESS="http://localhost:8080" # Address of the prover.
DATABASE_URL= "postgres://new_user:my_secure_password@localhost/my_new_database"
WEB_SERVER_ADDRESS="127.0.0.1:4500"
CIRCUITS_DIR_PATH= # Absolute path to packages/circuits
EMAIL_TEMPLATES_PATH= # Absolute path to packages/relayer/eml_templates
CANISTER_ID="q7eci-dyaaa-aaaak-qdbia-cai"
PEM_PATH="./.ic.pem"
IC_REPLICA_URL="https://a4gq6-oaaaa-aaaab-qaa4q-cai.raw.icp0.io/?id=q7eci-dyaaa-aaaak-qdbia-cai"
JSON_LOGGER=false
```
7. You should have your entire setup up and running!

NOTE: You need to turn on IMAP on the email id you’d be using for the relayer.

### Production on GCP
1. Install `kubectl` on your system (https://kubernetes.io/docs/tasks/tools/)
2. Setup k8s config of `zkemail` cluster on GKE,
`gcloud container clusters get-credentials zkemail --region us-central1 --project (your_project_name)`
3. One time steps (already done)
1. Create a static IP (https://cloud.google.com/vpc/docs/reserve-static-external-ip-address#gcloud)
2. Map the static IP with a domain from Google Domain
3. Create a `Managed Certificate` by applying `kubernetes/managed-cert.yml` (update the domain accordingly)
4. (Optional) Delete `db.yml` , `ingress.yml` and `relayer.yml` if applied already
5. (Optional) Build the Relayer’s Docker image and publish it.
6. Set the config in the respective manifests (Here, you can set the image of the relayer in `relayer.yml` , latest image already present in the config.)
7. Apply `db.yml`
8. Apply `relayer.yml` , ssh into the pod and run `nohup cargo run &` , this step should be done under a min to pass the liveness check.
9. Apply `ingress.yml`

## Specification
### Database
It has the following tables in the DB.
Expand Down

0 comments on commit 245b8d6

Please sign in to comment.