pepper-project / pequin

A system for verifying outsourced computations, and applying SNARKs. Simplified release of the main Pepper codebase.
Other
122 stars 46 forks source link

Seemingly unused assignments in .pws #42

Open fleupold opened 5 years ago

fleupold commented 5 years ago

I noticed that for a non-trivial app (not sure if the specifics of the code matter here), a large fraction of lines in the worksheet are of the form P Vx = Vy E (in my example ~33% of lines in .pws, accounting for 15% of total number of constraints). It seems like the left hand side of the assignment (Vx) is never referenced again in the .pws file (and even if it was we should be able to replace it with Vy).

I looked in the R1CS and the only constraint I found Vx used in was of the form 0 = (1*Vy) - (1*Vx)

I would like to filer out such constraints, as they don't seem to serve a purpose. Where do you think is the best place to do that? Should I try finding the type of assignment that causes the extra constraint or does it make more sense to run a post-processing step on the .pws/.qap files to see if there are further optimizations that can be done.

maxhowald commented 5 years ago

It might be possible to process the pws and qap files, but it's probably worth investigating first, whether the unused assignments are generated by the backend or the frontend of the compiler.

Specifically, can you tell if the unused assignments are present in the .circuit file, which is generated by the frontend (java), or just the .pws and .spec files, which are generated by the backend (python)?