This repo containts a Solidity contract based on the verifier contract created by ZoKrates, modified to verify boolean circuit TBCS (Two-Input Boolean Circuit Satisfiability) SNARKs. It also contains a second contract with a verifying key and proof hardcoded into the contract. The verifying key and proof were generated by libsnark from prime_under_16.
Boolean circuit-based SNARKs use different parameters than R1CS SNARKs, which neccessitates this modified version.
This part of libsnark was used as a reference to create the verifier contract.
The Solidity contracts in this file can be run using the Remix IDE, truffle.js, or web3.js.
The hardcoded_tbcs_verifer.sol contract can be run as-is on Remix IDE.
- First open the contract in Remix.
- Compile the code with the 0.5.11 version of the Solidity compiler.
- Deploy each of the three functions found in the contract:
BN256G2
,Pairing
, andVerifier
. - Once each has been deployed, simply run the
verifiyTx
function with no input data.
The general contract tbcs_verifer.sol can also run in Remix.
- First, get a verifying key and proof in JSON form. You can do this by running the
prime_under_16
binary from the libsnark-circuit repo, or you can you use the example data provided in [vk.json] and [proof.json] included in the repo. - Open the contract in Remix.
- Compile the contract using the 0.5.11 version of Solidity.
- Deploy each of the three functions in the contract : BN256G2, Pairing, and Verifier.
- Then run the
setVerifyingKey
function with thevk.json
data as input. - Then run the
verifyTx
function with theproof.json
data as input.