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

ACIR gen / ACVM: Handle predicates in non-inlined ACIR #4707

Closed
Tracked by #4426
vezenovm opened this issue Apr 3, 2024 · 1 comment
Closed
Tracked by #4426

ACIR gen / ACVM: Handle predicates in non-inlined ACIR #4707

vezenovm opened this issue Apr 3, 2024 · 1 comment
Labels
acir-gen enhancement New feature or request

Comments

@vezenovm
Copy link
Contributor

vezenovm commented Apr 3, 2024

Problem

We currently don't handle predicates in ACIR calls. For example this program where enable is false and input is not equal to 42 will fail.

fn main(
    value: Field,
    enable: bool
) -> pub Field {
    let mut result = 0;
    if enable { 
        result = assert_is_42(value);
    }
    result
}

#[fold]
fn assert_is_42(input: Field) -> Field {
    assert_eq(input, 42);
    input
}

Happy Case

We should handle predicates in ACIR function calls as we would expect if they were normally inlined. Simply adding a predicate to an ACIR Call opcode should be sufficient. This is because we expect the person proving the circuit to also be the one executing. The pseudocode in this comment is attempting to solve something that is not an issue for us. Needing to guarantee some certain call stack order is only necessary if we had someone else executing our circuit for us. In this case we would need a full VM to differentiate between incorrect execution and a malicious prover, which we do not need for an individual who is performing the proving themselves, as you trust yourself.

Project Impact

None

Impact Context

No response

Workaround

None

Workaround Description

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@vezenovm vezenovm added enhancement New feature or request acir-gen labels Apr 3, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Apr 3, 2024
@vezenovm vezenovm mentioned this issue Apr 3, 2024
@vezenovm vezenovm changed the title ACIR gen: Handle predicates in non-inlined ACIR ACIR gen / ACVM: Handle predicates in non-inlined ACIR Apr 3, 2024
vezenovm added a commit to AztecProtocol/aztec-packages that referenced this issue Apr 8, 2024
Resolves this issue noir-lang/noir#4707.

We simply add a `predicate` onto the Call opcode and handle it how we do
other predicates such as for Brillig opcodes and memory ops. I also made
a general utility method for checking a predicate in the VM as it now
happens for three different opcodes.

---------

Co-authored-by: AztecBot <[email protected]>
Co-authored-by: ludamad <[email protected]>
Co-authored-by: sirasistant <[email protected]>
Co-authored-by: Tom French <[email protected]>
AztecBot added a commit that referenced this issue Apr 8, 2024
…es#5616)

Resolves this issue #4707.

We simply add a `predicate` onto the Call opcode and handle it how we do
other predicates such as for Brillig opcodes and memory ops. I also made
a general utility method for checking a predicate in the VM as it now
happens for three different opcodes.

---------

Co-authored-by: AztecBot <[email protected]>
Co-authored-by: ludamad <[email protected]>
Co-authored-by: sirasistant <[email protected]>
Co-authored-by: Tom French <[email protected]>
AztecBot added a commit to AztecProtocol/barretenberg that referenced this issue Apr 9, 2024
Resolves this issue noir-lang/noir#4707.

We simply add a `predicate` onto the Call opcode and handle it how we do
other predicates such as for Brillig opcodes and memory ops. I also made
a general utility method for checking a predicate in the VM as it now
happens for three different opcodes.

---------

Co-authored-by: AztecBot <[email protected]>
Co-authored-by: ludamad <[email protected]>
Co-authored-by: sirasistant <[email protected]>
Co-authored-by: Tom French <[email protected]>
@vezenovm
Copy link
Contributor Author

Resolved by AztecProtocol/aztec-packages#5616

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

No branches or pull requests

1 participant