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

fix: check email length <= max #107

Open
wants to merge 1 commit 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
6 changes: 3 additions & 3 deletions packages/twitter-verifier-app/scripts/generate_input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export async function getCircuitInputs(
const address = bytesToBigInt(fromHex(eth_address)).toString();
const nullifier = signature[0];
// bytesToBigInt(fromHex()).toString();
const address_plus_one = (bytesToBigInt(fromHex(eth_address)) + 1n).toString();
// const address_plus_one = (bytesToBigInt(fromHex(eth_address)) + 1n).toString();

const USERNAME_SELECTOR = Buffer.from(STRING_PRESELECTOR);

Expand Down Expand Up @@ -207,9 +207,9 @@ export async function getCircuitInputs(
in_body_len_padded_bytes,
twitter_username_idx,
address,
address_plus_one,
// address_plus_one,
body_hash_idx,
// email_from_idx,
// email_from_idx: email_from_idx.toString(),
};
} else if (circuit === CircuitType.EMAIL_SUBJECT) {
// First word after "subject:" (usually send/Send)
Expand Down
6 changes: 6 additions & 0 deletions packages/twitter-verifier-circuits/twitter.circom
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ template TwitterVerifier(max_header_bytes, max_body_bytes, n, k, pack_size, expo
signal (from_regex_out, from_regex_reveal[max_header_bytes]) <== FromRegex(max_header_bytes)(in_padded);
log(from_regex_out);
from_regex_out === 1;

// ensure `from` email < max length allowed
var max_header_bytes_bits = log2_ceil(max_header_bytes);
signal max_email_len_selector <== QuinSelector(max_header_bytes, max_header_bytes_bits)(from_regex_reveal, email_from_idx+max_email_from_len);
max_email_len_selector === 0;

reveal_email_from_packed <== ShiftAndPack(max_header_bytes, max_email_from_len, pack_size)(from_regex_reveal, email_from_idx);
}

Expand Down