This source code is an efficient implemetation of MSM and zkSNARK using AVX-512IFMA. It is the artifact of the paper SimdMSM: SIMD-accelerated Multi-Scalar Multiplication Framework for zkSNARKs accepted to TCHES 2025.
There are three subfolders included in this repository:
AVX-MSM
: the MSM implementation instantiated with AVX512-IFMA engine based on the RELIC library. The specific implementation code can be found in theAVX-MSM/demo/381/
directory. The AVX512-IFMA engine implementation is based on Cheng et al.’s work.AVX-ZK
: integrating AVX-MSM implementation into the libsnark library. The part ofr1cs_gg_ppzksnark
, commonly known as the famous Groth16 protocol, is changed to using new AVX-MSM.jsnark
: a tool for evaluating the performance of AVX-ZK under different real-world workloads.
- Ubuntu 22.04.4
- gcc version 11.4.0
- cmake 3.22.1
- support AVX512-IFMA instruction sets
Target the SimdMSM
library.
$ cd AVX-MSM
$ cd demo/381/
$ make lib
Run AVX-MSM. The benchmark's data size num
and window size WSIZE
can be modified in the file /test/test_pip_ifma.c
.
$ make ifma
$ ./buile/test_pip_ifma
Run AVX-pair-MSM. The benchmark's data size num
and window size WSIZE
can be modified in the file /test/test_pair_ifma.c
.
$ make pair_ifma
$ ./buile/test_pair_ifma
Run AVX-MSM(muti-threads). The benchmark's data size num
and window size WSIZE
can be modified in the file /test/test_pip_threads.c
.
$ make ifma
$ ./buile/test_pip_threads
Run AVX-pair-MSM(muti-threads). The benchmark's data size num
and window size WSIZE
can be modified in the file /test/test_pair_threads.c
.
$ make pair_ifma
$ ./buile/test_pair_threads
Generate static link library libmsm.a
.
$ make msm
Cmake and create the Makefile:
$ cd AVX-ZK
$ mkdir build && cd build && cmake ..
Copy the libmsm.a
and librelic_s.a
.to libsnark/build/depends/libff/libff.
Then, to compile the library, run this within the build
directory:
$ make
Run the profiling of AVX-ZK.
$ make profile_r1cs_gg_ppzksnark
$ ./libsnark/profile_r1cs_gg_ppzksnark 1000 100 bytes
To compile the JsnarkCircuitBuilder project via command line, from the jsnark directory:
$ cd jsnark
$ cd JsnarkCircuitBuilder
$ mkdir -p bin
$ javac -d bin -cp /usr/share/java/junit4.jar:bcprov-jdk15on-159.jar $(find ./src/* | grep ".java$")
Run AES.
$ java -cp bin examples.generators.blockciphers.AES128CipherCircuitGenerator
Run SHA-256.
$ java -cp bin examples.generators.hash.SHA2CircuitGenerator
Run RSAEnc.
$ java -cp bin examples.generators.rsa.RSAEncryptionCircuitGenerator
Run Merkle-Tree.
$ java -cp bin examples.generators.hash.MerkleTreeMembershipCircuitGenerator
Run RSASigVer.
$ java -cp bin examples.generators.rsa.RSASigVerCircuitGenerator
Run Auction.
$ java -cp bin examples.generators.augmenter.AugmentedAuctionCircuitGenerator