Writing the App Contract
Last updated
Last updated
Your app contract needs to inherit the BrevisApp
abstract contract. You can manually copy the required contracts from the , or install Brevis contracts via
Notice that we have a vkHash storage variable in the contract:
handleProofResult
is where you process the computation result output from your circuit. There are two steps we must do before we use the proven data:
Check if the param _vkHash
matches our stored vkHash. This verifies the identity of the circuit which produced the computation result.
Decode the param _circuitOutput
.
We know in our circuit we did:
Therefore, this is how we decode _circuitOutput
in the contract:
By setting this variable to our , when Brevis calls our app contract, we can check the proof, that Brevis has verified before calling our contract, is indeed generated by our circuit.
The output values in your circuit definition are packed in the form of abi.encodePacked(...)
. The order of the variables is the same as the order you call the in the circuit.
If you are following this example to build the project, you can deploy this contract. If you are just doing research and would like to see a deployed version, see the on Sepolia.