Skip to content
/ vimz Public
forked from zero-savvy/vimz

ZK proofs for image authenticity

License

Notifications You must be signed in to change notification settings

azarpoor/vimz

 
 

Repository files navigation

VIMz: Verifiable Image Manipulation via Folding-based zkSNARKs DOI

Generated by AI (Freepik.com) Cover generated by FreePik

VIMz is currently (Dec. 2023) the fastest and most efficient program to proof authenticity of transformed/editted images w.r.t. an original source. It is built on top of NOVA recursive zkSNARKs with the front-end of Nova-Scotia (using Circom language for defining internal circuits). The protocol supports image resolutions of up to 4K (3840 x 2160) and higher.

Reference

Ppaper: [2024] Dziembowski, Ebrahimi, Hassanizadeh, VIMz: Verifiable Image Manipulation using Folding-based zkSNARKs

Installation

I-Prerequisites

I-a) For Installing Node JS:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

source ~/.bashrc

nvm install v16.20.0

Note

in rare cases (miss-configured Linux distros), if you got an error stating that version "v16.20.0" was not found; following command might help: export NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist

I-b) For installing snarkjs:

npm install -g snarkjs

I-c) For installing Rust:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y

I-d) Additional build-essential libraries and packages:

sudo apt install gcc

sudo apt install build-essential nlohmann-json3-dev libgmp3-dev nasm

I-e) For installing Circom:

git clone https://github.com/iden3/circom.git

cd circom

cargo build --release

cargo install --path circom

II-Installing VIMz

Once you have installed dependencies, you can proceed with setting up and running VIMz. To obtain the latest version of VIMz, clone its GitHub repository using the following command:

git clone https://github.com/zero-savvy/vimz.git

II-a) Installing VIMz itself

Head to the nova directory: cd vimz/nova

build and install vimz using cargo:

cargo build

cargo install --path .

verify installation of vimz:

vimz --help

II-b) Building Circuits

go to the circuits directory:

cd vimz/circuits

build node modules:

npm install

build ZK circuits using the provided script in this directory:

./build-circuits.sh

How to Use

vimz --function <FUNCTION>
--resolution <RESOLUTION> --input <FILE>
--circuit <R1CS FILE> --output <FILE>  
--witnessgenerator <BINARY/WASM FILE>

Benchmarks

We've built the tools necessary for benchmarking using the samples provided in the samples directory. To do this, simply Go to the main directory of vimz repo and run any number of transformations as you prefer using the provided script:

./benchmark.sh [list-of-transformations]

Example 1: benchmarking a single transformation:

./benchmark.sh contrast
     or
./benchmark.sh blur
     or
./benchmark.sh grayscale

Example 2: benchmarking parallel execution of multiple transformations:

./benchmark.sh contrast blur
     or
./benchmark.sh resize blur shapness

Note

Since the proof generation process can be time consuming, it is recommended to initially benchmark with only one transformation at a time~(replicating the results presented in Table IV of the paper). Once these results are verified, you can proceed to run multiple transformations in parallel to replicate the results shown in Table V.

Sample output: The script generates a file (or multiple files, one per given transformation) with a .output suffix in the same directory. These files contain the standard output of running the vimz command directly, as shown in Figure below. The output includes various performance metrics. The total proof generation time can be calculated as the sum of two numbers: RecursiveSNARK creation and CompressedSNARK::prove: from the output.

output VIMz STD output

Acknowledgement

  1. We thank @iden3 for building the awesome Circom language and provding the CircomLib.
  2. This work currently heavily relies on Nova-Scotia's compiler for transforming Circom circuits to the ones comptible with Nova.
  3. The very early version of the project (solely based on Circom without NOVA) was inspired by image transformation proofs from @TrishaDatta's Circom circuits repository,
    which were related to the medium post By Trisha Datta and Dan Boneh.

License

This work is licensed under Attribution-NonCommercial 4.0 International

About

ZK proofs for image authenticity

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Circom 53.2%
  • Rust 18.6%
  • Python 16.3%
  • Shell 7.4%
  • Solidity 4.5%