YAP - Yet Another Parser - CirC's IR parser for PEEV project.
YAP parses the intermediate representation of CirC into the Operations List (OpL). The OpL is used in PEEV to create a program based on the BGV homomorphic encryption scheme with Rinocchio ZKP.
The benchmarks directory includes the programs used to evaluate the framework. Each subdirectory has 3 files:
- .zok - the source code of the program written in Z#.
- .ir - the intermediate repersentation of CirC.
- .opl - the parsed IR that is passed to PEEV.
The parse.cpp file is the parser source code. YAP supports only instructions that are compatible with homomorphic encryption (e.g., addition and multiplication). The following list of instructions are parsed by YAP: bvadd
, bvsub
, bvmul
, bv2pf
, select
, array
, store
, =
, not
, ite
, #
for defining a value, and '
for referencing an index.
git clone https://github.com/OmarAlmighty/YAP.git
cd YAP
mkdir build && cd build && cmake ..
cd .. && cmake --build build
Then navigate to the binary path and pass the IR file as a command-line argument. e.g.,
Parser.exe dot_product_v8.ir
There will be two ouptut files: .py
used for debugging and testing purposes, and .opl
that is passed to PEEV.
If you want to write your program in CirC, you will need to modify it to print the IR:
- Go to the
circ.rs
file: https://github.com/circify/circ/blob/6133414b44b8892e25f2c1803f2f87624ccf1d6e/examples/circ.rs#L298-L302 - Append the following line:
println!("{0}", circ::ir::term::text::serialize_computation(cs));
- So, your code will look like this:
...
trace!("IR: {}", circ::ir::term::text::serialize_computation(cs));
let mut r1cs = to_r1cs(cs, cfg());
println!("{0}", circ::ir::term::text::serialize_computation(cs));
println!("Pre-opt R1cs size: {}", r1cs.constraints().len());
...
The project needs Boost library.
This work was supported by the National Science Foundation (Award #2239334).