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

derive_generators doesn't properly catch non-constant starting_index before compiler panics #7064

Open
leovido opened this issue Jan 14, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@leovido
Copy link

leovido commented Jan 14, 2025

Aim

Compile with no issues

Expected Behavior

To compile without any errors

Bug

This happens when I run nargo compile

Here is the code:

fn main(age_commit: pub Field, age: u8, expected_age: pub u8, age_blinding: u32) -> pub bool {
    let age_field = [age as Field];
    let recomputed_age_commit = std::hash::pedersen_hash_with_separator(age_field, age_blinding);

    let commit_valid = (recomputed_age_commit == age_commit);

    let comparison = (age >= expected_age);

    assert(commit_valid & comparison)
    commit_valid & comparison
}

Image

To Reproduce

  1. Start a new Nargo project
  2. Copy the main function
  3. Run nargo compile
  4. Expect error

Workaround

None

Workaround Description

No response

Additional Context

No response

Project Impact

None

Blocker Context

No response

Nargo Version

nargo version = 1.0.0-beta.1 noirc version = 1.0.0-beta.1+03b58fa2dfcc8acc8cf5198b1b23b55676fbdb02 (git version hash: 03b58fa, is dirty: false)

NoirJS Version

No response

Proving Backend Tooling & Version

0.66.0

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@leovido leovido added the bug Something isn't working label Jan 14, 2025
@TomAFrench
Copy link
Member

TomAFrench commented Jan 14, 2025

Hey, this shouldn't be panicking but it's also not expected that this should compile correctly. The separator argument must be known at compile-time so we don't support programs like the above.

For your purposes I'd recommend including the blinding term as part of the hash.

Thank you for reporting this!

@TomAFrench TomAFrench changed the title Crash when using pedersen_hash_with_separator derive_generators doesn't properly catch non-constant starting_index before compiler panics Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants