zkSNARK Implementation on Ourchain
Introduction
Blockchain is a public ledger, which means that all of the data is open to be viewed by others. Recently, programmability and privacy have become the two main issues of cryptocurrency. Therefore, we would like to allow users to submit their data with smart contracts while preserving their sensitive data from being revealed.
Servey
- Hawk: The Blockchain Model of Cryptography and Privacy-Preserving Smart Contracts in 2016 was the first paper to propose the structure to preserve privacy and programmability at the same time
- ZoKrates - Scalable Privacy-Preserving Off-Chain Computations in 2018 provided an off-chain toolbox to realize a Zero-knowledge protocol on Ethereum blockchain
How ZoKrates work
We want to use this toolbox to provide a C-language based blockchain called Ourchain with privacy-preserving functionality
Ourchain
- Ourchain is built based on Bitcoin but with Economically Proof-of-Work protocol and with C-language smart contracts
Implementation
- We used gmp library to implement an elliptic curve which ZoKrates used, but we had difficulties in the function pairing.
- I fixed this problem in September 2019
Evaluation
Ethereum gas
- The more public inputs, the more gas in deployment and calling smart contracts
Ourchain Transaction Fee
- The more inputs also increase the transaction fee in deployment, but they are invariant while calling smart contracts
- We suggest that Ourchain should have a protocol to calculate transaction fees according to the smart contracts’ complexity
Transaction Fees | Deploy | Call |
---|---|---|
Sudoku Checker | 54380 | 5620 |
if a*a==b | 10940 | 5440 |
ECC addition | 116760 | 5460 |
ECC multiplication | 113480 | 5260 |
ECC multiplication * 7 | 139980 | 5260 |