Skip to content

Commit

Permalink
fix: check email length <= max
Browse files Browse the repository at this point in the history
  • Loading branch information
lonerapier committed Sep 24, 2023
1 parent 9f68bc8 commit f74cef2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
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

0 comments on commit f74cef2

Please sign in to comment.