microsoft / Spartan

Spartan: High-speed zkSNARKs without trusted setup
MIT License
690 stars 121 forks source link

Add example proving knowledge of cubic equation solution #26

Closed kubkon closed 4 years ago

kubkon commented 4 years ago

The example of knowing a solution to the cubic equation of x^3 + x + 5 = y is effectively the first thing you come across when dissecting the zkSNARKs knowledge if your background is in blockchain. This is probably thanks to Vitalik who decomposes the problem into the primitives in his blog post here.

This commit adds this as a working example to Spartan repo.

ghost commented 4 years ago

CLA assistant check
All CLA requirements met.

kubkon commented 4 years ago

cc @srinathsetty

srinathsetty commented 4 years ago

Thanks @kubkon for adding the example!

Could you please sign the CLA so I can merge?

kubkon commented 4 years ago

EDIT: @srinathsetty I've added a build step to the CI config so that examples are also always built. In the meantime, it seems there's been a regression in the nightly compiler and one of the project's deps fails to build anymore (packed_simd to be exact). As a temp solution I've made sure the CI uses the latest toolchain that was known to have been still functional (nightly-2020-09-15 to be exact).

srinathsetty commented 4 years ago

@kubkon Great, thanks! I’ll merge this shortly.

I had a quick question: in your example, it seems like x is a public input. Wouldn’t it make more sense to have y as public input and x as secret witness?

kubkon commented 4 years ago

@kubkon Great, thanks! I’ll merge this shortly.

I had a quick question: in your example, it seems like x is a public input. Wouldn’t it make more sense to have y as public input and x as secret witness?

You're absolutely right, thanks for spotting that one @srinathsetty! I've now fixed it in 7715fd5 :-)