Skip to main content

gcc

sudo apt install build-essential
gcc --version

rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
rustc --version
cargo --version

cmake

sudo apt install cmake
sudo apt install clang

ip

ip addr show

将 coding 改为 tmp 一样的权限


# 设置目录权限为 1777
chmod 1777 /coding

# 验证权限
ls -ld /coding

gmp

apt install libgmp-dev
dpkg -l | grep gmp

vi/vim


apt install vim

# 验证安装
vi --version
vim --version

nlohmann/json

apt install nlohmann-json3-dev
dpkg -l | grep nlohmann-json3-dev

nasm

sudo apt install nasm
nasm -v

node

sudo apt install -y nodejs
sudo apt install -y npm

disable volta

~/.zshrc
# export VOLTA_HOME="$HOME/.volta"
# export PATH="$VOLTA_HOME/bin:$PATH"

zkp

npm install -g snarkjs
snarkjs --version
# rust环境
npm install -g circom
circom --version

circom

git clone https://github.com/iden3/circom
cd circom
git switch -d v2.1.7
cargo build --release
cargo install --path circom

snarkjs


# 编译电路

# js
circom example.circom --r1cs --wasm --sym
# cpp
circom example.circom --r1cs --wasm --sym --c

# 生成 witness
node example_js/generate_witness.js example_js/example.wasm input.json witness.wtns

# 生成 proving key 和 verification key
snarkjs groth16 setup example.r1cs pot12_final.ptau circuit_final.zkey

# 生成证明
snarkjs groth16 prove circuit_final.zkey witness.wtns proof.json public.json

# 生成 verification_key.json
snarkjs zkey export verificationkey circuit_final.zkey verification_key.json

# 验证证明
snarkjs groth16 verify verification_key.json public.json proof.json



# sol
snarkjs zkey export solidityverifier circuit_final.zkey verifier.sol

alt text

alt text