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

VmProcessor does not work for more complex information flow #2203

Open
georgwiese opened this issue Dec 6, 2024 · 0 comments
Open

VmProcessor does not work for more complex information flow #2203

georgwiese opened this issue Dec 6, 2024 · 0 comments

Comments

@georgwiese
Copy link
Collaborator

Consider this example:

let N = 4;

namespace Test(N);
    col fixed ISLAST(i) { if i == N - 1 { 1 } else { 0 } };
    col fixed INDEX(i) { i };
    col witness w, sum;

    // Compute the witness from the index
    w = INDEX + 1;

    // The sum should be the sum of all witnesses, op to the current row.
    sum' = (1 - ISLAST) * sum + w';

    // Note that adding this equivalent constraint resolves the issue.
    // sum' = (1 - ISLAST) * sum + (INDEX' + 1);

This can be solved by running the following steps:

  • Process w = INDEX + 1 in row 0:
    • -> Set w[0] = 1
  • Process sum' = (1 - ISLAST) * sum + w' on row 3:
    • -> Set sum[0] = 1
  • Process w = INDEX + 1 in row 1:
    • -> Set w[1] = 2
  • Process sum' = (1 - ISLAST) * sum + w' on row 0:
    • -> Set sum[1] = 3
  • ...

Instead, the VM processor never figures our a value of sum and eventually sets it to 0, violating the constraints. To see that, run:
cargo run pil test.pil -o output -f --export-witness-csv --prove-with mock

The reason is that w = INDEX + 1 needs to processed on the next row before sum' = (1 - ISLAST) * sum + w can be completed on the current row.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant