ZK-SecreC is a programming language for expressing statements that we may want to prove under zero-knowledge (ZK), using a protocol for ZK proofs. Having gotten its start from DARPA's SIEVE program, the compiler for ZK-SecreC is capable of translating ZK-SecreC programs into the common intermediate representation of SIEVE. The compiler is also able to directly interface with several ZK proof backends. The compiler and its documentation are publicly available.
This repository contains examples of ZK-SecreC. This hopefully complement the documentation, allowing for a shallower learning curve and faster exploitation. The examples consist of several small examples, as well as a few larger use-cases that have been built using ZK-SecreC.
The following examples are in the following folders:
examplesfolder contains several small examples, each of which demonstrates a single feature and/or solves a single small task.income-source-checkfolder contains an example of parsing files in comma-separated value format, reading values from them, and checking that these values obey some "business logic". The parsing, reading, and checking happens under ZK.face-recognitionfolder contains an implementation of face recognition under zero-knowledge. Several machine-learning methods have been implemented in ZK-SecreC for this purpose.alg-approxfolder contains a method for evaluating elementary functions under zero-knowledge.log-processingfolder an example of substring checks, making sure that multiple search strings are, or are not a part of a longer text.electric-vehiclefolder contains the source code of our "electric vehicle demo app". It consists of several variations of checking that a geographic trajectory is long enough, while being located mostly in a given geographic area.highway-taxfolder contains a statement stating that a geographic trajectory has followed a certain highway for no more than a given distance. It is a spinoff use case of the electric vehicle demo.medical-checksfolder contains an example of checking credentials (in the mDL format) in zero-knowledge.zkbppfolder contains an example of anonymous authentication to access some resource in blockchain, while using the credentials provided by some external identity provider. It reimplements zkLogin, includes a ZKP backend based on the MPC-in-the-head technique (a heavily modified version of ZKB++), and manages to create the proof with efficiency that makes the proof generation feasible to be run in user's web browser.
Each folder contains its own README.md file, describing the example or examples in this folder.
ZK-SecreC design and tool development has been funded by the Defense Advanced Research Projects Agency (DARPA) under contract HR0011-20-C-0083. The views, opinions, and/or findings expressed are those of the author(s) and should not be interpreted as representing the official views or policies of the Department of Defense or the U.S. Government. Distribution Statement "A" (Approved for Public Release, Distribution Unlimited).