.zkey and .ptau deserializer for gnark groth16 bn254 trusted setup
Convert a .ptau file to a .ph1 file:
go run main.go convert --input <CEREMONY>.ptau --output <CEREMONY>.ph1Initialize phase2 of the trusted setup ceremony using the semaphore-mtb-setup coordinator (wrapper of gnark/backend/groth16/bn254/mpcsetup):
go run main.go initialize --input <FILE>.ph1 --r1cs <CIRCUIT>.r1cs --output <FILE>.ph2Download a .zkey file from the PSE Snark artifact page for semaphore by running the following command:
wget https://www.trusted-setup-pse.org/semaphore/16/semaphore.zkey -O deserialize/semaphore_16.zkeyDownload the .ptau file from the snarkjs repository by running the following command:
wget https://storage.googleapis.com/zkevm/ptau/powersOfTau28_hez_final_08.ptau -O deserialize/08.ptauFor larger .ptau files, checkout the snarkjs repository's README for more information.
Remember that you need sufficiently high powers of tau ceremony to generate a proof for a circuit with a given amount of constraints:
2^{POWERS_OF_TAU} >= CONSTRAINTS
To get a sample r1cs file from semaphore-mtb, checkout the semaphore-mtb repository and run the following command:
git clone https://github.com/worldcoin/semaphore-mtb.git && git checkout wip/mk/r1cs-export
go build
./gnark-mbu r1cs --tree-depth=10 --batch-size=15 --output=demo_smtb.r1csMove the file to into deserialize directory:
mv semaphore-mtb/demo_smtb.r1cs ptau-deserializer/deserialize/demo_smtb.r1csIf you want to see the byte representation of the .ptau file, run the following command:
hexdump -C deserialize/08.ptau > deserialize/08.ptau.hexSame applies for the .zkey file:
hexdump -C deserialize/semaphore_16.zkey > deserialize/semaphore_16.zkey.hexTo test, run:
cd deserialize && go test -v