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

Refactor circuit #185

Merged
merged 47 commits into from
Apr 6, 2024
Merged

Refactor circuit #185

merged 47 commits into from
Apr 6, 2024

Conversation

saleel
Copy link
Member

@saleel saleel commented Mar 28, 2024

Description

  • EmailVerifier: Renamed signal names; minor refactoring like rearranging variables, updating comments, etc

    • in_padded -> emailHeader
    • in_len_padded_bytes -> emailHeaderLength
    • body_hash_idx -> bodyHashIndex
    • precomputed_sha -> precomputedSHA
    • in_body_padded -> emailBody
    • in_body_len_padded_bytes -> emailBodyLength
    • pubkey_hash -> pubkeyHash
  • VarShiftLeft: Moved to utils/array.circom;

  • QuinSelector: Moved to utils/array.circom; renamed to ItemAtIndex; Removed the second parameter of numBits and calculate it internally (log2Ceil(maxLength))

  • AssertZeroes: Moved to utils/array.circom; renamed to AssertZeroPadding;

  • Packed2Bytes: Removed - it was not used anywhere;

  • Bytes2Packed and PackBytes: Removed and replaced with Bytes2Ints from email wallet - single circuit that does int[] to bytes[] - Bytes2Packed was doing "assign and then constrain later" which is not the case in Bytes2Ints; Renamed and added as PackBytes in bytes.circom.

  • ShiftAndPack: Moved to utils/bytes.circom; Renamed to PackByteSubArray; Added logic to set value after subarray length (new input) to zero as packing without this is not safe (using a new circuit SelectSubArray in array.circom); we dont use these two circuits anywhere though; set packsize to 31

  • VarShiftMaskedStr: Moved to utils/regex.circom; Renamed to ExtractRegexReveal; added assertions to check data after maxRevealLength is zero (old TODO); Renamed shift to startIndex

  • ShiftAndPackMaskedStr: moved to utils/regex.circom; Renamed to PackRegexReveal; use 31 as pack size instead of template param

  • ClearSubarrayAfterEndIndex: Removed - it was not used anywhere; also seems to have off by one error.

  • ascii.circom was removed. Moved and renamed the similar circuit from email wallet to utils/bytes.circom (DigitBytesToInt)

  • fp.circom, base64.circom, 'bigint.circom', bigint_func.circom (changed _ to - in filename) moved to lib

  • sha.circom, sha256general.circom, sha256partial.circom merged to one file sha.circom and moved to lib; inputs in_padded and in_len_padded_bytes renamed to paddedIn and paddedInLength in all sha circuits; removed unused/commented out Sha256NBytes circuit

  • rsa.circom moved to lib/rsa.circom; renamed to RSAVerifier65537 (from RSAVerify65537); base_message input renamed to message

  • log2 - removed as this was off by one; replaced usages with log2Ceil

  • log2Ceil - moved to utils/functions.circom

  • Some constants (field max bytes, max length for domain, email addr) from email wallet moved to utils/constants.circom

  • Email nullifier from email wallet moved to helpers/nullifier.circom

  • PoseidonLarge circuit added to utils/hash.circom to hash large number of inputs; This is used to hash pub key in EmailVerifier and hash signature in EmailNullifier circuit

  • Update all circuits to pragma 2.1.6

  • Update input generation helper to use new input names

  • Update tests to match new circuits

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • I have discussed with the team prior to submitting this PR
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes

@saleel saleel changed the base branch from Docs-update to main March 28, 2024 07:43
@saleel saleel changed the base branch from main to v4 April 1, 2024 16:55
Copy link

socket-security bot commented Apr 1, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/circom_tester@0.0.20 filesystem, shell 0 33.6 kB jbaylina

🚮 Removed packages: npm/child_process@1.0.2, npm/circom_tester@0.0.19

View full report↗︎

@saleel saleel marked this pull request as ready for review April 1, 2024 17:26
// from nozee (emmaguo13, sehyunc, kaylee)
// https://github.com/emmaguo13/zk-blind/blob/master/circuits/ascii.circom
// only converts ascii to numbers from 0-9
template AsciiToNum (max_input) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is imported from Nozee so shouldn't be deleted, but moved to string utils

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ascii.circom was removed. Moved and renamed the similar circuit from email wallet to utils/bytes.circom (DigitBytesToInt)

We already had a similar circuit in email wallet which was imported here. So this one was deleted.

@saleel saleel merged commit 66fea7a into v4 Apr 6, 2024
5 checks passed
@saleel saleel deleted the feat/circuit-refactor branch April 6, 2024 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants