Skip to content

An Ethereum smart contract that verifies TBCS (Two-Input Boolean Circuit Satisfiability) SNARKs

Notifications You must be signed in to change notification settings

statebox/solidity-zksnark-verifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Running a Contract

The Solidity contracts in this file can be run using the Remix IDE, truffle.js, or web3.js.

Running the hardcoded verifier with Remix IDE

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, and Verifier.
  • Once each has been deployed, simply run the verifiyTx function with no input data.

Running the general conract with Remix IDE

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 the vk.json data as input.
  • Then run the verifyTx function with the proof.json data as input.

About

An Ethereum smart contract that verifies TBCS (Two-Input Boolean Circuit Satisfiability) SNARKs

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published