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

Readme/constraint breakdown for the email wallet #100

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ This is a simplified flow, but underneath we use many parameters to ensure secur
## ☞ Directory structure
This is a mono-repo that contains the circom circuits, smart contracts, the relayer and a prover server.

### Circuits and Constraints:
*Total Constraints Across All Circuits*: **3,999,432**


<br />

- `packages/circuits` contains the circom circuits, tests, scripts to generate zkeys, vkeys, and helper functions to generate circuit inputs.
- `packages/contracts` contains the solidity contracts, tests, and scripts to deploy the wallet.
- `packages/relayer` contains the relayer code - relayer listens to IMAP server, generate proof using prover server, and call the contract.
Expand Down Expand Up @@ -124,13 +130,15 @@ saved here.
├── /subgraph # indexing and querying events generated by circuits.


```


<br />

## ☞ Building and Running

The total number of constraints across all circuits is **3,999,432**.

- Refer to the [circuit docs](./packages/circuits/README.md) for more details on building and testing circuits.
- Refer to the [contract docs](./packages/contracts/README.md) for more details on building and testing contracts.
- Refer to the [relayer docs](./packages/relayer/README.md) for more details on building and running relayer.
Expand All @@ -148,12 +156,11 @@ And to serve the website:
mdbook serve
```


## References
1. S. Suegami and K. Shibano, "Contract Wallet Using Emails," 2023 IEEE International Conference on Blockchain and Cryptocurrency (ICBC), Dubai, United Arab Emirates, 2023, pp. 1-2, doi: 10.1109/ICBC56567.2023.10174932.

<br />
<hr />
<br />

☆ Built using [zk-email](https://github.com/zkemail/zk-email-verify) ☆
☆ Built using [zk-email](https://github.com/zkemail/zk-email-verify) ☆
13 changes: 8 additions & 5 deletions packages/circuits/src/email_sender.circom
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ template EmailSender(n, k, max_header_bytes, max_subject_bytes) {
signal output has_email_recipient;
signal output recipient_email_addr_commit;

// Verify Email Signature
// VERIFY EMAIL SIGNATURE : 669650 constraints
component email_verifier = EmailVerifier(max_header_bytes, 0, n, k, 1);
email_verifier.in_padded <== in_padded;
email_verifier.pubkey <== pubkey;
Expand All @@ -66,19 +66,21 @@ template EmailSender(n, k, max_header_bytes, max_subject_bytes) {
signal header_hash[256] <== email_verifier.sha;
pubkey_hash <== email_verifier.pubkey_hash;

// FROM HEADER REGEX
// FROM HEADER REGEX : 643296 constraints
signal from_regex_out, from_regex_reveal[max_header_bytes];
(from_regex_out, from_regex_reveal) <== FromAddrRegex(max_header_bytes)(in_padded);
from_regex_out === 1;
signal sender_email_addr[email_max_bytes];
sender_email_addr <== VarShiftMaskedStr(max_header_bytes, email_max_bytes)(from_regex_reveal, sender_email_idx);

// SUBJECT HEADER REGEX
// SUBJECT HEADER REGEX : 99208 constraints
signal subject_regex_out, subject_regex_reveal[max_header_bytes];
(subject_regex_out, subject_regex_reveal) <== SubjectAllRegex(max_header_bytes)(in_padded);
subject_regex_out === 1;
signal subject_all[max_subject_bytes];
subject_all <== VarShiftMaskedStr(max_header_bytes, max_subject_bytes)(subject_regex_reveal, subject_idx);

// EMAIL ADDRESS REGEX : 92037 constraints
signal recipient_email_regex_out, recipient_email_regex_reveal[max_subject_bytes];
(recipient_email_regex_out, recipient_email_regex_reveal) <== EmailAddrRegex(max_subject_bytes)(subject_all);
has_email_recipient <== IsZero()(recipient_email_regex_out-1);
Expand All @@ -97,6 +99,7 @@ template EmailSender(n, k, max_header_bytes, max_subject_bytes) {
recipient_email_addr[i] <== shifted_email_addr[i] * has_email_recipient;
}

// INVITATION CODE REGEX WITH PREFIX : 43494 constraints
signal code_regex_out, code_regex_reveal[max_subject_bytes];
(code_regex_out, code_regex_reveal) <== InvitationCodeWithPrefixRegex(max_subject_bytes)(subject_all);
signal has_code <== IsZero()(code_regex_out-1);
Expand All @@ -113,7 +116,7 @@ template EmailSender(n, k, max_header_bytes, max_subject_bytes) {
}
masked_subject_str <== Bytes2Ints(max_subject_bytes)(masked_subject_bytes);

// DOMAIN NAME HEADER REGEX
// DOMAIN NAME HEADER REGEX : 38219 constraints
signal domain_regex_out, domain_regex_reveal[email_max_bytes];
(domain_regex_out, domain_regex_reveal) <== EmailDomainRegex(email_max_bytes)(sender_email_addr);
domain_regex_out === 1;
Expand All @@ -129,7 +132,7 @@ template EmailSender(n, k, max_header_bytes, max_subject_bytes) {

email_nullifier <== EmailNullifier()(sign_hash);

// Timestamp regex + convert to decimal format
// Timestamp regex + convert to decimal format : 233872 constraints
signal timestamp_regex_out, timestamp_regex_reveal[max_header_bytes];
(timestamp_regex_out, timestamp_regex_reveal) <== TimestampRegex(max_header_bytes)(in_padded);
// timestamp_regex_out === 1;
Expand Down
Loading