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

"Separate subgraph" bug misfires on indirect Brillig call with return value #7292

Open
michaeljklein opened this issue Feb 5, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@michaeljklein
Copy link
Contributor

Aim

Attempted to compile a program that calls an unconstrained function and asserts that the result is zero:

unconstrained fn foo<T>(_x: T) -> Field {
    0
}

fn bar<T>(x: T) -> Field {
    /// Safety: test
    unsafe { foo(x) }
}

fn main() {
    let x: Field = 0;
    assert(bar(x) == 0);
}

Expected Behavior

Expected the program to compile without errors or bug's.

Bug

nargo compile returns:

bug: Input to Brillig function is in a separate subgraph to output
  ┌─ src/main.nr:7:14
  │
7 │     unsafe { foo(x) }
  │              ------ There is no path from the output of this Brillig call to either return values or inputs of the circuit, which creates an independent subgraph. This is quite likely a soundness vulnerability
  │
  = Call stack:
    1. src/main.nr:12:12
    2. src/main.nr:7:14

However, the Brillig call is completely constrained:

  • All arguments to foo are constrained (i.e. constant)
  • foo's result is constrained to be zero

To Reproduce

Workaround

Yes

Workaround Description

Ignore bug warning

Additional Context

No response

Project Impact

Nice-to-have

Blocker Context

No response

Nargo Version

nargo version = 1.0.0-beta.1 noirc version = 1.0.0-beta.1+3a42eb5c68f9616f0ebe367c894f0376ba41e0ef (git version hash: 3a42eb5, is dirty: false)

NoirJS Version

No response

Proving Backend Tooling & Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@michaeljklein michaeljklein added the bug Something isn't working label Feb 5, 2025
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Feb 5, 2025
@TomAFrench
Copy link
Member

I think this is a case where the error message can be improved but we should still throw a bug/warning. While all of the values returned from the oracle call are fully constrained, it's in a separate subgraph from the rest of the circuit the unconstrained function isn't really doing anything.

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
Status: 📋 Backlog
Development

No branches or pull requests

2 participants