arkworks-rs / dpc

A library for decentralized private computation
https://ia.cr/2018/962
Apache License 2.0
18 stars 5 forks source link

Use DPC with non-trivial predicate #4

Open sam-steffen opened 3 years ago

sam-steffen commented 3 years ago

How can I use DPC to instantiate the very simple "conserve" predicate required to encode the basic user-defined asset from the reference paper [1]?

I could not figure out how to do this. The current implementation hardcodes an "always accept" predicate and it's unclear how to instantiate the "conserve" predicate: the sum of inputs should equal the sum of outputs.

[1] https://eprint.iacr.org/2018/962

sam-steffen commented 3 years ago

My current plan seems much more complicated than expected; am I on the right track?

Step 1: Create R1CS It seems like I'd have to implement the ConstraintSynthesizer trait generating a R1CS for the predicate. But, how can I represent the "conserve" predicate as a R1CS? I know there are reductions from arithmetic circuits to R1CS [2] but don't know a standalone tool which automates this (I could not figure out how to do this in libsnark).

Step 2: Integrate predicate The "always accept" predicate EmptyPredicateCircuit is hard-coded in the plain_dpc module (even outside the tests). Hence, I'd have to refactor the code to allow a different predicate.

[2] https://eprint.iacr.org/2013/507.pdf