Code Monkey home page Code Monkey logo

ptau-deserializer's Introduction

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

ptau-deserializer's People

Contributors

dcbuild3r avatar kustosz avatar kobigurk avatar

Forkers

renovate-bot

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.