{"id":25633092,"url":"https://github.com/zkemail/relayer","last_synced_at":"2026-06-15T19:30:20.449Z","repository":{"id":167581278,"uuid":"621491180","full_name":"zkemail/relayer","owner":"zkemail","description":"The V0 rust IMAP + SMTP server that reads email via imap, generates a zk proofs either locally or on an on-demand AWS machine with modal, then replies and sends on-chain. **DEPRECATED** in favor of V1 relayer in email-wallet.","archived":false,"fork":false,"pushed_at":"2024-03-27T05:11:48.000Z","size":560,"stargazers_count":12,"open_issues_count":7,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-04-14T02:13:13.291Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zkemail.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-03-30T19:15:14.000Z","updated_at":"2024-03-27T05:09:16.000Z","dependencies_parsed_at":"2023-10-20T20:44:16.702Z","dependency_job_id":"649d4990-9739-48d3-b7af-92285d1a0129","html_url":"https://github.com/zkemail/relayer","commit_stats":null,"previous_names":["zkemail/relayer"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkemail%2Frelayer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkemail%2Frelayer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkemail%2Frelayer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkemail%2Frelayer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zkemail","download_url":"https://codeload.github.com/zkemail/relayer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240240280,"owners_count":19770273,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-22T21:27:56.337Z","updated_at":"2026-06-15T19:30:20.397Z","avatar_url":"https://github.com/zkemail.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Relayer\n\nThis is the **DEPRECATED** V0 relayer. The code has since been upgraded to [email-wallet/packages/relayer](https://github.com/zkemail/email-wallet/tree/main/packages/relayer), which is the V1 relayer.\n\nA permissionless Rust IMAP + SMTP server that reads email via imap, creates zk proofs of it, and replies to it. Uses IMAP to receive email and SMTP to send replies.\n\nGoerli Wallet Address (circom-only): 0x3b3857eaf44804cce00449b7fd40310e6de6496e\n\n## Setup\n\nIn a new cloud instance, install Rust:\n\n```sh\ncurl https://sh.rustup.rs -sSf | sh\n```\n\nAnd then:\n\n```sh\nsudo apt update\nsudo apt install -y pkg-config libssl-dev build-essential libfontconfig1-dev\ncargo build --release\nchmod +x src/circom_proofgen.sh\n```\n\nIf you want to run a local prover, also run:\n\n```\nchmod +x ../rapidsnark/build/prover\nip -4 -o addr show scope global | awk '{print $4}' \u0026\u0026 ip -6 -o addr show scope global | awk '{print $4}' # Point the DNS to these raw IPs\n```\n\nAnd make sure that the abi in `abi/wallet.abi` is up to date.\n\n## Enable TLS/TCP Keepalive\n\nFrom [here](https://aws.amazon.com/blogs/networking-and-content-delivery/implementing-long-running-tcp-connections-within-vpc-networking/), or else your IMAP connection will drop every 6ish idle minutes. Edit: Apparenly this is not enough.\n\n```sh\necho -e \"net.ipv4.tcp_keepalive_time = 45\\nnet.ipv4.tcp_keepalive_intvl = 45\\nnet.ipv4.tcp_keepalive_probes = 9\" | sudo tee -a /etc/sysctl.conf\nsudo sysctl -p\n```\n\n## Tests\n\n### Test Chain\n\nTest chain connection to verify that your connection to the chain works and simple tx's will send.\n\n```sh\ncargo test\n```\n\n### Test proofgen\n\nTo test local proofgen, send `relayer@sendeth.org` an email while relayer is running then run\n\n```sh\n./src/circom_proofgen.sh\n```\n\n\n## Run\n\nFirst, run the relayer.\n\n```sh\ncargo run relayer\n```\n\n### Run infra\n\nThen run the prover + infrastructure coordinator.\n\n```sh\nsudo apt install python3-pip awscli\npip3 install -r requirements.txt\naws configure\npython3 coordinator.py\n```\n\n## Update the docker file\n\nNote that this dir structure is only needed if you want to regenerate the docker image.\n```\n-\n  - zk-email-verify\n    - ...\n  - relayer\n    - ...\n  - rapidsnark\n    - ...\n```\n\nNote that you'll have to populate the build folder, run `make` in `zk-email-verify/build/email/email_cpp`, and install rapidsnark according to the zk-email-verify README.\n\nIf you want to edit the Dockerfile or compile a new image, copy it one folder up (for now) and setup with these commands:\n\nSetup:\n\n```sh\ncp Dockerfile ..\ncd ..\nsudo docker login\n# This command is needed so that git cargo dependencies in docker can be pulled\necho -e '\\n[url \"ssh://\"]\\n\\tinsteadOf = git://' \u003e\u003e ~/.gitconfig\n```\n\nYou have to compile the zk-email-verify, relayer, and rapidsnark directories.\n\nRecompile:\n\n```sh\nsudo docker build -t zkemail-modal . \u0026\u0026 sudo docker tag zkemail-modal aayushg0/zkemail-modal:modal \u0026\u0026 sudo docker push aayushg0/zkemail-modal:modal\n```\n\nAnd edit the tag in coordinator.py. To re-deploy the modal instance, do\n\n```\nmodal token set --token-id \u003ctokenid\u003e --token-secret \u003ctokensecret\u003e\nmodal deploy --name aayush coordinator.py\n```\n\nTo hit it, take the resulting URL and hit\n\n```\ncurl 'https://ziztuww--aayush-test.modal.run?\u003cquery params\u003e'\n```\n\n## Server Setup\n\nWe don't use this server anymore, but if you'd like to call these functions via endpoints, you can use this nginx setup.\n\n```\nsudo apt-get install nginx certbot python3-certbot-nginx\n```\n\n### Turn on nginx\n\n````\nConfigure Nginx: Create a new Nginx configuration file for your application:\n\n```sh\nsudo nano /etc/nginx/sites-available/sendeth\n````\n\nPaste the following configuration and adjust the domain name and paths accordingly:\n\n```\nserver {\n        listen 80;\n        server_name sendeth.org www.sendeth.org;\n        return 301 https://$host$request_uri;\n}\n\nserver {\n        listen 443 ssl;\n        server_name sendeth.org www.sendeth.org;\n\n        ssl_certificate /etc/letsencrypt/live/sendeth.org/fullchain.pem;\n        ssl_certificate_key /etc/letsencrypt/live/sendeth.org/privkey.pem;\n    ssl_protocols TLSv1.3 TLSv1.2;\n    ssl_prefer_server_ciphers on;\n    ssl_dhparam /etc/nginx/dhparam.pem;\n        ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GS256-GCM-SHA384:EECDH+AESGCM:EDH+AESGCM'\n\n        location / {\n                proxy_pass http://localhost:3000;\n                proxy_set_header Host $host;\n                proxy_set_header X-Real-IP $remote_addr;\n                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n                proxy_set_header X-Forwarded-Proto $scheme;\n        }\n}\n```\n\nWe rely on gmail for IMAP, but if you want your own server, you can add thiss:\n\n```\nmail {\n    server_name sendeth.com;\n\n    imap_capabilities \"IMAP4rev1\" \"UIDPLUS\";\n\n    server {\n        listen 143;\n        protocol imap;\n    }\n\n    server {\n        listen 993 ssl;\n        protocol imap;\n        ssl_certificate /etc/letsencrypt/live/sendeth.com/fullchain.pem;\n        ssl_certificate_key /etc/letsencrypt/live/sendeth.com/privkey.pem;\n    }\n}\n```\n\nSave and exit the file. Create a symbolic link to enable the site:\n\n```bash\nsudo ln -s /etc/nginx/sites-available/sendeth /etc/nginx/sites-enabled/\n```\n\nTest the Nginx configuration and restart Nginx:\n\n```sh\nexport YOURDOMAIN=sendeth.org\nsudo certbot --nginx -d $YOURDOMAIN -d www.$YOURDOMAIN\n```\n\n### Enable IMAP in Gmail\n\nHere's how to enable IMAP access and use App Passwords for your Gmail or Google Workspace account:\n\nEnable IMAP:\n\na. Sign in to your Gmail or Google Workspace account.\nb. Click the gear icon in the top-right corner and select \"See all settings.\"\nc. Go to the \"Forwarding and POP/IMAP\" tab.\nd. In the \"IMAP access\" section, select \"Enable IMAP.\"\ne. Click \"Save Changes.\"\n\nCreate an App Password (recommended):\n\na. Go to your Google Account settings: https://myaccount.google.com/\nb. In the left-hand menu, click \"Security.\"\nc. In the \"Signing in to Google\" section, click on \"App Passwords.\" (Note: This option will only be available if you have 2-Step Verification enabled.)\nd. Click on \"Select app\" and choose \"Mail\" from the dropdown menu.\ne. Click on \"Select device\" and choose the device you're using or select \"Other\" to enter a custom name.\nf. Click \"Generate.\"\ng. Google will generate a 16-character App Password. Make sure to copy and save it securely, as you won't be able to see it again.\n\nNow, when connecting to Gmail or Google Workspace via IMAP, use your email address as the \"imap id\" (username) and the generated App Password as the \"password.\" If you have not enabled 2-Step Verification and are using \"Less secure apps\" access, you can use your regular email password instead of the App Password. However, using App Passwords is recommended for enhanced security.\n\n### Enable ports in AWS\n\nIf there's an error, make sure your ports are open and traffic is allowed. This will be a massive pain in the \\*\\*\\* so just stay with me while 3 hours of your life dissapate to nonsensical setups. Ensure that your EC2 instance has port 80 and 443 open in the security group to allow incoming traffic. You can check and update your security group settings from the AWS EC2 Management Console.\n\nStep 0 is make sure to always add your IPv4 and IPv6 addresses to A and AAAA records respectively for both @ and www in DNS settings of the domain.\n\nThen, enable inbound traffic. To do so, follow these steps:\n\n0. Log in to the AWS Management Console.\n1. Navigate to the EC2 Dashboard.\n2. Select \"Security Groups\" from the left sidebar.\n3. Find the security group associated with your EC2 instance and click on its name.\n4. Click on the \"Inbound rules\" tab.\n5. For the server, check if there are rules allowing traffic on ports 80 and 443. If not, add the rules by clicking on \"Edit inbound rules\" and then \"Add rule\". Choose \"HTTP\" for port 80 and \"HTTPS\" for port 443, and set the source to \"Anywhere\" or \"0.0.0.0/0\" (IPv4) and \"::/0\" (IPv6). For IMAP, click on \"Add rule\" and create new rules for the necessary IMAP ports (143 and 993) with the following settings:\n\n- Type: Custom TCP\n- Protocol: TCP\n- Port Range: 143 (for IMAP) or 993 (for IMAPS)\n- Source: Choose \"Anywhere\" for both IPv4 and IPv6 (0.0.0.0/0 for IPv4 and ::/0 for IPv6)\n\n0. To rnable IPv6 support for your VPC (Virtual Private Cloud), go to the VPC Dashboard in the AWS Management Console, select your VPC, click on \"Actions\", and then click on \"Edit CIDRs\". Add an IPv6 CIDR block.\n1. Enable IPv6 support for your subnet. Go to the \"Subnets\" section in the VPC Dashboard, select the subnet associated with your EC2 instance, click on \"Actions\", and then click on \"Edit IPv6 CIDRs\". Add an IPv6 CIDR block.\n2. Enable IPv6 support for your EC2 instance. Go to the EC2 Dashboard in the AWS Management Console, select your instance, click on \"Actions\", and then click on \"Manage IP Addresses\". Assign an IPv6 address to your instance's network interface.\n3. Update your instance's security group to allow inbound IPv6 traffic, if necessary.\n4. If needed, configure your operating system to use IPv6. This step depends on the OS you're using. For most Linux distributions, IPv6 is enabled by default.\n\nTo enable the security group traffic, run these:\n\n0. Log in to the AWS Management Console and navigate to the EC2 Dashboard: https://console.aws.amazon.com/ec2/\n1. In the left-hand menu, click on \"Security Groups\" under the \"Network \u0026 Security\" section.\n2. Locate the security group associated with your instance. You can find the security group in the instance details in the \"Instances\" section of the EC2 Dashboard.\n3. Select the security group and click on the \"Inbound rules\" tab in the lower panel.\n4. Click \"Edit inbound rules.\"\n5. Click \"Add rule\" to create a new rule.\n6. Choose the desired rule type (e.g., \"HTTP\" for port 80, \"HTTPS\" for port 443, or \"Custom TCP\" for other ports). In the \"Source\" field, select \"Anywhere-IPv6\" to allow traffic from all IPv6 addresses. You can also specify a custom IPv6 range in CIDR notation (e.g., 2001:db8::/32).\n7. Click \"Save rules\" to apply the changes.\n\nThen in AWS EC2 shell, run\n\n```sh\nsudo ufw enable\nsudo ufw allow http\nsudo ufw allow https\nsudo ufw allow ssh\nsudo ufw allow 3000\n```\n\nThen run the certbot command again.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzkemail%2Frelayer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzkemail%2Frelayer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzkemail%2Frelayer/lists"}