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

Constrain bits after max len to be 0 #54

Open
Divide-By-0 opened this issue Feb 3, 2024 · 1 comment
Open

Constrain bits after max len to be 0 #54

Divide-By-0 opened this issue Feb 3, 2024 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers low

Comments

@Divide-By-0
Copy link
Member

Fix this line: https://github.com/zkemail/zk-email-verify/blob/03cf8c66472ce3ac177a0089c56c0e78481d3391/packages/circuits/helpers/extract.circom#L114

    // Note that this technically doesn't constrain the rest øf the bits after the max_substr_len to be 0/unmatched/unrevealed
    // Because of the constraints on signed inputs, it seems this should be OK security wise
    // But still, TODO unconstrained assert to double check they are 0
    for (var i = 0; i < max_substr_len; i++) {
        packer.in[i] <== shifter.out[i];
    }
    for (var i = 0; i < max_substr_len_packed; i++) {
        out[i] <== packer.out[i];
    }
@Divide-By-0 Divide-By-0 added bug Something isn't working good first issue Good for newcomers high labels Feb 3, 2024
@Divide-By-0 Divide-By-0 changed the title Finish TODO in helpers Constrain bits after max len to be 0 May 19, 2024
@Divide-By-0 Divide-By-0 added low and removed high labels May 19, 2024
@brolag
Copy link

brolag commented Jul 18, 2024

Hi @Divide-By-0,

I would like to work on this issue. To ensure that the bits after the max_substr_len are constrained to zero, I propose the following solution:

  • Add Assertion: Introduce an assertion after the loops to ensure that all bits beyond max_substr_len are zero.
  • Code Modification: Modify the extract.circom file to include this check. Here’s how we can achieve this:
    for (var i = max_substr_len; i < in_array_len; i++) {
        assert(in[i] == 0, "Bit out of range must be 0");
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers low
Projects
None yet
Development

No branches or pull requests

2 participants