halo2 icon indicating copy to clipboard operation
halo2 copied to clipboard

Design a way to "pin" the result of floor planning

Open str4d opened this issue 2 years ago • 2 comments

Circuits need to specify the floor planner that they use, because the floor planner has explicit power to alter the structure of the circuit (and thus the verifying key). Once a circuit has been completed and deployed, re-running the floor planner is pointless busywork, as the verifying key is pinned (as input to the Fiat-Shamir transform). But currently every user of a deployed circuit runs their chosen floor planner (e.g. floor_planner::V1 for Orchard) every time a proof is created.

We should have a way to encode the layed-out circuit in some way, and then feed that into the prover so that Circuit::synthesize is called precisely once (to assign the per-instance witnesses), instead of e.g. twice for floor_planner::V1. This could probably just become part of the ProvingKey, both in-memory (i.e. each user of a circuit computes the layout once on startup and then caches it for all proofs), and eventually stored in a serialized form (#443).

str4d avatar Apr 12 '22 17:04 str4d

This pinned format might also end up being how other implementations of Halo 2 interoperate (e.g. some other frontend that can produce Halo 2 circuits could pass that data to halo2_proofs as a backend), but that's a secondary concern (that may end up being solved in other ways).

str4d avatar Apr 16 '22 07:04 str4d

The description of the duplicate #117 was:

I think it should be possible to dump an optimized configuration + floor plan in serialized form (e.g. as Rust code that constructs it), and load it back in rather than doing the region sizing / floorplanning / optimization at run time. For Pollard we can use a single combined core and do such optimizations by hand if they're applicable. But I'd like to make sure that the API is such that they could be done automatically.

daira avatar Jul 08 '22 14:07 daira