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

Making prover_knows_factorization fail #64

Closed ani-majumdar closed 5 years ago

ani-majumdar commented 5 years ago

I am trying to get a better sense for how all the code works and as an exercise, am trying to make the verification for prover_knows_factorization fail. In particular, I tried changing the factors listed in exo1 to something that doesn't multiply to 301 (e.g., 5 and 43 instead of 7 and 43). I would have expected that the verification fails if I do this, but I still receive "VERIFICATION SUCCESSFUL" at the end of the process. I am wondering if it would be possible to explain why this is the case and provide some quick instructions on how I can make the verification for this example fail (i.e., I'd like a way to actually check if the factors listed in exo1 multiply to 301). Thank you!

maxhowald commented 5 years ago

I'm pretty sure this is expected behavior.

If you look at the source for that example, you can see that if the prover doesn't know the factors (because the values in exo1 are wrong), then the output of the computation is set to 0: https://github.com/pepper-project/pequin/blob/f638ab26a7677305c804a6a71cab704f2d479318/pepper/apps/prover_knows_factorization.c#L36-L40

So, if you change the the values in exo1 and re-run the prover / verifier, you should see the output (in prover_verifier_shared/prover_knows_factorization.outputs) change from 1 to 0. The prover is honest, so it produces a correct proof that it doesn't know the factors, and the verification succeeds.

If you want to introduce some dishonesty or bugginess into the prover, you could try modifying the proof returned in pepper_prover.cpp.

ani-majumdar commented 5 years ago

Thanks very much for your response -- all of that makes sense. I think what's throwing me off is that I'm not seeing the expected behavior you described. In particular, the output (in prover_knows_factorization.outputs) is 0 no matter what (i.e., whether I provide the correct factors or the incorrect ones). I would appreciate it if you could confirm if this is a bug. Thank you!

maxhowald commented 5 years ago

Did you copy exo1 from the apps dir to the bin dir? The way exo_compute works is that it looks for a program named exo[n] in the pepper/bin dir, where n is the last argument to the exo_compute() call. (In the example, n = 1). The exo programs in the apps dir are just examples. (This is a bit clunky, of course, but it is documented in exo_compute.txt).

Contents of prover_verifier_shared/prover_knows_factorization.outputs after this:

0
1

0 is the return value of the compute function, 1 is the output of the program.

ani-majumdar commented 5 years ago

Ah, I see now -- I hadn't done that. Thanks very much for your quick responses!