Skip to content

.ptau deserializer for gnark groth16 bn254 trusted setup

License

Notifications You must be signed in to change notification settings

unionlabs/ptau-deserializer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ptau-deserializer

.zkey and .ptau deserializer for gnark groth16 bn254 trusted setup

Usage

Convert a .ptau file to a .ph1 file:

go run main.go convert --input <CEREMONY>.ptau --output <CEREMONY>.ph1

Initialize 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>.ph2

Setup

Download 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.zkey

Download the .ptau file from the snarkjs repository by running the following command:

wget https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_08.ptau -O deserialize/08.ptau

For 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.r1cs

Move the file to into deserialize directory:

mv semaphore-mtb/demo_smtb.r1cs ptau-deserializer/deserialize/demo_smtb.r1cs

If you want to see the byte representation of the .ptau file, run the following command:

hexdump -C deserialize/08.ptau > deserialize/08.ptau.hex

Same applies for the .zkey file:

hexdump -C deserialize/semaphore_16.zkey > deserialize/semaphore_16.zkey.hex

Testing

To test, run:

cd deserialize && go test -v

About

.ptau deserializer for gnark groth16 bn254 trusted setup

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%