diff --git a/base-image/Dockerfile b/base-image/Dockerfile new file mode 100755 index 0000000..f29f76e --- /dev/null +++ b/base-image/Dockerfile @@ -0,0 +1,183 @@ +FROM ubuntu:22.04 AS base +SHELL ["/bin/bash", "--rcfile", "/root/.bashrc", "-lc"] + +# === install some basic tools and libs === + +RUN apt-get -y update && \ + apt-get -y install curl wget vim less build-essential git \ + libgmp-dev zlib1g zlib1g-dev pkg-config libffi-dev \ + libdigest-sha3-perl + +RUN echo -e "\nalias dir=\"ls -la\"" >>$HOME/.bashrc + +RUN mkdir /zk && mkdir /zk/versions + +# === install python === + +RUN apt -y install python3 && \ + echo -e "\nalias python=python3" >>$HOME/.bashrc && \ + python3 --version >/zk/versions/python.txt + +# === install clang === + +RUN apt-get -y install clang && \ + clang --version >/zk/versions/clang.txt + +# === install LLVM === + +RUN apt -y install llvm && \ + llvm-ar --version >/zk/versions/llvm.txt + +# -- NOTE: this would install `llvm-*-16` instead of `llvm-*` which we need... +# RUN apt -y install lsb-release wget software-properties-common gnupg && \ +# cd /tmp && \ +# wget https://apt.llvm.org/llvm.sh && \ +# chmod u+x llvm.sh && \ +# ./llvm.sh 16 + +# === install node.js === + +ENV MY_NVM_VERSION="v20.2.0" + +RUN cd /tmp && \ + curl --proto '=https' --tlsv1.2 https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh -sSf >install_nvm && \ + chmod u+x install_nvm && \ + ./install_nvm && \ + source $HOME/.nvm/nvm.sh && \ + nvm install $MY_NVM_VERSION && \ + nvm use $MY_NVM_VERSION && \ + rm ./install_nvm && \ + echo -e "\nsource /root/.nvm/nvm.sh" >>$HOME/.bashrc && \ + nvm --version >/zk/versions/nvm.txt && \ + npm --version >/zk/versions/npm.txt && \ + node --version >/zk/versions/node.txt + +# === install Rust === + +RUN curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf >install_rustup && \ + chmod u+x install_rustup && \ + echo -e "\n" >>$HOME/.bashrc && \ + sh ./install_rustup -y && \ + rm ./install_rustup && \ + export PATH="$HOME/.cargo/bin:$PATH" && \ + rustc --version >/zk/versions/rustc.txt + +# === install nim === + +RUN cd /tmp && \ + echo -e "\n" >>$HOME/.bashrc && \ + curl --proto '=https' --tlsv1.2 https://nim-lang.org/choosenim/init.sh -sSf >install_choosenim && \ + chmod u+x install_choosenim && \ + sh ./install_choosenim -y && \ + echo -e "\nexport PATH=/root/.nimble/bin:\$PATH" >>$HOME/.bashrc && \ + export PATH=/root/.nimble/bin:$PATH && \ + choosenim stable && \ + nimble --version >/zk/versions/nimble.txt && \ + nim --version >/zk/versions/nim.txt && \ + rm -rf /tmp/* + +# === install Haskell === + +RUN cd /tmp && \ + apt-get install -y libffi-dev libffi8ubuntu1 libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5 && \ + curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org >install_ghcup && \ + chmod u+x install_ghcup && \ + BOOTSTRAP_HASKELL_NONINTERACTIVE=1 sh ./install_ghcup && \ + source /root/.ghcup/env && \ + echo -e "\nsource /root/.ghcup/env" >>$HOME/.bashrc && \ + ghcup --version >/zk/versions/ghcup.txt + +RUN source /root/.ghcup/env && \ + ghc --version >/zk/versions/ghc.txt && \ + cabal --version >/zk/versions/cabal.txt && \ + rm /tmp/install_ghcup && \ + ghcup upgrade && \ + ghcup install cabal 2.4.1.0 && \ + ghcup set cabal 2.4.1.0 && \ + ghcup install ghc 8.6.5 && \ + ghcup set ghc 8.6.5 && \ + ghc --version >/zk/versions/ghc.txt && \ + cabal --version >/zk/versions/cabal.txt && \ + cabal update + +# === install circom & snarkjs === + +RUN cd /tmp && \ + git clone https://github.com/iden3/circom.git && \ + cd circom && \ + source $HOME/.bashrc && \ + cargo build --release && \ + cargo install --path circom && \ + circom --version >/zk/versions/circom.txt && \ + rm -rf /tmp/circom + +RUN source /root/.nvm/nvm.sh && \ + npm install -g snarkjs && \ + (snarkjs --version >/zk/versions/snarkjs.txt || true) + +# === install go === + +ENV GO_TAR_FNAME="go1.20.4.linux-amd64.tar.gz" + +RUN cd /tmp && \ + wget https://go.dev/dl/$GO_TAR_FNAME && \ + tar -C /usr/local -xzf $GO_TAR_FNAME && \ + export PATH=$PATH:/usr/local/go/bin && \ + echo -e "\nexport PATH=\$PATH:/usr/local/go/bin" >>$HOME/.bashrc && \ + go version >/zk/versions/go.txt && \ + rm -rf /tmp/$GO_TAR_FNAME + +# === download and build constantine === + +RUN (mkdir /zk/src || true) && \ + cd /zk/src && \ + git clone https://github.com/mratsim/constantine + +RUN export PATH=/root/.nimble/bin:$PATH && \ + cd /zk/src/constantine && \ + CC=clang nimble bindings && \ + nimble test_bindings + +RUN export PATH=/root/.nimble/bin:$PATH && \ + cd /zk/src/constantine && \ + nimble install + +# === download gnark === + +RUN (mkdir /zk/src || true) && \ + cd /zk/src && \ + git clone https://github.com/ConsenSys/gnark + +# === download circomlib === + +RUN (mkdir /zk/src || true) && \ + (mkdir /zk/circuits || true) && \ + cd /zk/src && \ + git clone https://github.com/iden3/circomlib && \ + cp -r /zk/src/circomlib/circuits /zk/circuits/circomlib + +# === download and build MCL === + +RUN (mkdir /zk/src || true) && \ + cd /zk/src && \ + git clone https://github.com/herumi/mcl + +RUN cd /zk/src/mcl && \ + make -j4 + +# === download and/or copy some powers of tau files === + +# note: +# - 2^16 = 75 megabytes +# - 2^20 = 1.2 gigabytes +# - 2^24 = 19 gigabytes + +# RUN cd /zk/ptau && \ +# wget https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_8.ptau && \ +# wget https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_12.ptau && \ +# wget https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_16.ptau + +# RUN mkdir /zk/ptau +# COPY ./ptau /zk/ptau + + diff --git a/base-image/README.md b/base-image/README.md new file mode 100755 index 0000000..657dfe6 --- /dev/null +++ b/base-image/README.md @@ -0,0 +1,39 @@ + +ZK benchmarking Docker image +============================ + +This is a Docker image intended for experimenting with and benchmarking various ZKP implementations. + +It should have many of the standard tools, for example: + +- languages: node.js, Rust, Haskell (GHC), Nim, Go, Python3 +- circom, snarkjs, rapidsnark, circomlib +- libraries: arkworks, gnark, constantine... +- perpetual powers of tau ceremony files +- etc + + +Building +-------- + +Build it with: + + $ docker build . -t zk-bench + +Note: this will take a *long time*. +After it (hopefully) finished, you can +Test the image with an interactive shell: + + $ docker run -it zk-bench + +or with terminal colors enabled: + + $ docker run -e "TERM=xterm-256color" -it zk-bench + + +Using +----- + +Hopefully the tools will work, and you will find stuff under `/zk`. + + diff --git a/base-image/ptau/README.md b/base-image/ptau/README.md new file mode 100755 index 0000000..4d91403 --- /dev/null +++ b/base-image/ptau/README.md @@ -0,0 +1,26 @@ + +Powers of tau files +=================== + +These are universal reference string for pairing based SNARK-s (KZG, Groth16, etc) using the bn128 elliptic curve. + +Different sizes are available: + +- 2^8 (380 kB) +- 2^12 (4.8 MB +- 2^16 (75 MB) +- 2^20 (1.2 GB) +- 2^22 (4.8 GB) + +Links: +----- + +- [read here about the ceremony](https://medium.com/coinmonks/announcing-the-perpetual-powers-of-tau-ceremony-to-benefit-all-zk-snark-projects-c3da86af8377) +- [challenge / response history](https://github.com/weijiekoh/perpetualpowersoftau) @ Koh Wei Jie github +- [challenge / response history](https://github.com/privacy-scaling-explorations/perpetualpowersoftau) @ Ethereum Privacy Scaling Exploration +- the files were downloaded [from the links in the snarkjs repo](https://github.com/iden3/snarkjs) (scroll down) + +File format +----------- + +TODO diff --git a/base-image/run.sh b/base-image/run.sh new file mode 100755 index 0000000..46ffd1e --- /dev/null +++ b/base-image/run.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker run -e "TERM=xterm-256color" -it zk-bench:latest