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

Calling a function that returns more than two registers corrupts the registers of the caller #1976

Closed
sirasistant opened this issue Jul 19, 2023 · 0 comments · Fixed by #1973
Labels
brillig Unconstrained functions / brillig IR bug Something isn't working

Comments

@sirasistant
Copy link
Contributor

Aim

Running this:

global VALUE_NOTE_LEN: Field = 4;

struct ValueNote {
    value: Field,
    x: Field,
    y: Field,
    is_real: bool,
}

impl ValueNote {
    fn deserialise(preimage: [Field; VALUE_NOTE_LEN]) -> Self {
        ValueNote {
            value: preimage[0],
            x: preimage[1],
            y: preimage[2],
            is_real: preimage[3] as bool,
        }
    }
}

unconstrained fn main(fields: [Field; VALUE_NOTE_LEN]) -> pub ValueNote {
    ValueNote::deserialise(fields)
}

Expected Behavior

With this prover.toml :

fields = [0x0000000000000000000000000000000000000000000000000000000000000001, 0x0000000000000000000000000000000000000000000000000000000000000002, 0x0000000000000000000000000000000000000000000000000000000000000003, 0x0000000000000000000000000000000000000000000000000000000000000001]

the verifier.toml should be

[return]
is_real = true
value = "0x0000000000000000000000000000000000000000000000000000000000000001"
x = "0x0000000000000000000000000000000000000000000000000000000000000002"
y = "0x0000000000000000000000000000000000000000000000000000000000000003"

Bug

actual returned value:

[return]
is_real = false
value = "0x0000000000000000000000000000000000000000000000000000000000000001"
x = "0x0000000000000000000000000000000000000000000000000000000000000002"
y = "0x0000000000000000000000000000000000000000000000000000000000000001"


To Reproduce

Installation Method

None

Nargo Version

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

Yes

Support Needs

No response

@sirasistant sirasistant added the bug Something isn't working label Jul 19, 2023
@jfecher jfecher added the brillig Unconstrained functions / brillig IR label Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
brillig Unconstrained functions / brillig IR bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants