A question about ZK-SNARKS



I am thinking of building a game on the Ethereum network and I stumbled on a problem, that is it is generally hard to hide information on that platform. So I have heard of ZK-SNARKS in relation to ZCash so I thought this would be a good place to ask a question I have.

So what I am trying to do goes as follows:

I have a function that takes a list of parameters, call it f(x1,x2,x3,…). It is supposed to be a complex function, in that it should be hard to predict how the value changes when you change one of the parameters. Now I want to hide this function, so computing it on the blockchain is out of the question. But I still want to minimise the trust needed in this game, so I thought of the following scheme:

  1. Publish a proof of the form: “there exists a function f, and it hashes (in some encoding) to the value h”, before the game begins.
  2. Then every time the function is used, publish a proof like "the function that hashes to h has value y for input list (x1,x2,x3,…).
  3. When the game ends, reveal f so that anyone can verify that it indeeds hashes to h.

So my question is: is this even possible? If so, any resource recommendation for implementing this?



Also, would it be possible to generate such a function without even me knowing it, and then also publishing some sort of proof no-one knows the function?


will the game live on the blockchain or will there be some sort of interface(client or server sided?)

I don’t see why zk proof would be useful in your case, i mean, what you’re asking has been implemented in so many ways and in some many different enviroments, without context I can’t figure out a scenario where you would need this for a game…


Hi, thanks for the reply.

All the game logic would live on the blockchain, save for computing this function, which I want to do off-chain and then use some sort of oracle to inject the value into the blockchain.

The idea in the game is to have players try to find the maximum of this function.



Really interesting,
i would love to see your end result, I’m a big fan of oracle implementation :smiley:

For your purpose I would suggest you enigma blockchain, I believe they’ve implemented secret smart contracts (or are about too), I havn’t followed it to closely, but I wrote down some notes as a valueable development enviroment.

Best of luck in the meanwhile :smiley: