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

Compilation flag to add runtime checks for opcode assumptions #6275

Closed
michaeljklein opened this issue Oct 10, 2024 · 1 comment · Fixed by #6716
Closed

Compilation flag to add runtime checks for opcode assumptions #6275

michaeljklein opened this issue Oct 10, 2024 · 1 comment · Fixed by #6716
Assignees
Labels
enhancement New feature or request

Comments

@michaeljklein
Copy link
Contributor

Problem

Some ACIR opcodes have built-in assumptions about their inputs/outputs, e.g.

  • Whether a point is on the curve and/or at infinity
  • An input/output being within a range (if integral) or of a specific size (if array-like)
  • Public key(s) are valid(?)

These assumptions are expected to be checked at some point throughout compilation, but

  1. They're exclusively runtime checks
  2. They're checked at different locations and/or passes
  3. They could be checked earlier in compilation and then invalidated later, e.g. by an SSA pass

Happy Case

Add a compilation flag to generate runtime code to check such assumptions, perhaps --pedantic or --pedantic-gen

  • This flag would only be used for testing, since it would be expected to have a negative impact on performance (and should be redundant)
  • This would be especially useful for fuzzing, where otherwise assumptions can be broken silently

Workaround

Yes

Workaround Description

A partial workaround is to manually trace the dependencies of a piece of user code to their ACVM opcodes and add such runtime checks, however:

  • This only works for individual and specific pieces of user code
  • It would be challenging to keep up to date, especially without feature flags

Additional Context

No response

Project Impact

Nice-to-have

Blocker Context

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@michaeljklein michaeljklein added the enhancement New feature or request label Oct 10, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Oct 10, 2024
@michaeljklein michaeljklein changed the title Compilation flag to add Compilation flag to add runtime checks for opcode assumptions Oct 10, 2024
@Rumata888
Copy link
Collaborator

This would be really nice to protect us from shooting ourselves in the foot. If we implement fuzzing for noir programs, it would also have a benefit as an extended bug oracle. Would be great

@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants