-
When we use hint functions, it's important that the written constraints be able to detect wrong hints. How can I write tests that use some fake and invalid hint functions to test this? Ideally I wouldn't want to pass the hint function as a parameter to my functions. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 12 replies
-
Even though a malicious prover could replace hint functions, then I think gnark doesn't provide directly a way to provide incorrect hint function to the prover. We distinguish between hint functions based on I think the most fastest option would be to separate hint function behaviour based on some (global) variable. But I think a cleaner solution would be to provide a prover option which allows to provide a hint function with some particular ID. A hint function can be called several times in a circuit. Would you see a need for having different hint replacements during different calls? It would be more difficult, but still doable (we export a map of wire IDs->hint Fns and allow individual replacement etc.). And just to add, anonymous functions do not work really well with hint functions. The main idea is that the prover can be a standalone process from the compiler. And then if the package containing anonymous function is not imported, then prover also cannot use the hint function. |
Beta Was this translation helpful? Give feedback.
-
Is it ? Technically, the output of the hint functions can be seen as witness (user input); the constraints should hold no matter what the hint outputs; The hints are really a "convenience" at the constraint system level (it helps the solver assign a value to some wires because solving it "automatically" would be too compute intensive), but from a prover perspective, the actual soundness of constraints don't depend on the actual hint. |
Beta Was this translation helpful? Give feedback.
Even though a malicious prover could replace hint functions, then I think gnark doesn't provide directly a way to provide incorrect hint function to the prover. We distinguish between hint functions based on
id = Hash(Name(hintFn))
wherehintFn
is a function reference,Name
returns fully qualified function name andHash
is some checksum function. So theid
of the prover provided hint must be same what compiler has stored for solving some wires.I think the most fastest option would be to separate hint function behaviour based on some (global) variable. But I think a cleaner solution would be to provide a prover option which allows to provide a hint function with some particular ID.
A hint…