Skip to content

Public inputs improvement to Cairo Verifier #727

Open
@MauroToscano

Description

@MauroToscano

Currently public inputs are not given a pre verification. The following tasks improve robustness of the verifier:

  • Change the proving mode with a trace to actually use public memory (This may need a small PR to the cairo VM to add a derive deserialize to the public inputs, so we can load it)
  • Add an option to take a compiled program with proof mode from Cairo0, and use that code to check the public memory, enforcing the program used is the given one
  • Add an option to take a Cairo (1) Program as an input. Inside the code should be updated as the Cairo1 Proof Mode in the VM. Then public memory constraints should be applied.
  • Add small checks from the Starkex Verifier (rc min < rc max, etc)
  • Investigate additional checks to be added

For the first task, this is the recommended approach:

We have the public inputs here

https://github.com/lambdaclass/cairo-vm/blob/8f2ddf818f2797cd1a38486b646a09384fd71f9e/vm/src/air_public_input.rs#L59-L68

The VM currently serializes the public inputs in the same format as the old python VM, but can't deserialize because that's something it doesn't need. Now, since we have everything written in rust, it may be easier to just add the deserialize there in the Cairo VM. Most of the work is just adding a Deserialize derive everywhere. If I remember correctly the problem comes here

https://github.com/lambdaclass/cairo-vm/blob/8f2ddf818f2797cd1a38486b646a09384fd71f9e/vm/src/air_public_input.rs#L66-L67

Since layout_params is a reference to something that is not in the public input, Serde can't derive how to create the data type.

We can start by replicating the PublicInput assuming there are no relevant layout params, or that we can write whatever we need ourselves (Like in plain layout). And then add a From method to transform this new struct that can be something like PublicInputForDeserializer, to the real PublicInput. And if we have this it's easy to include in the proof or use them to verify.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions