Skip to content

mysteryon88/gnark-to-snarkjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gnark to snarkjs

Go Reference

Utilities for exporting gnark proofs and verifying keys into a format compatible with snarkjs.
Currently supports Groth16 on curves BN254 and BLS12-381.

Installation

go get github.com/mysteryon88/gnark-to-snarkjs@latest

Example

Here is a full example with a simple circuit, proof generation, verification, and exporting proof + verifying key into snarkjs-compatible JSON.

import (
    "os"
    gnarktosnarkjs "github.com/mysteryon88/gnark-to-snarkjs"
    groth16_bn254 "github.com/consensys/gnark/backend/groth16/bn254"
)

// proof: *groth16_bn254.Proof or *groth16_bls12381.Proof
var proof = getProof()
proof_out, _ := os.Create("proof.json")
err = gnarktosnarkjs.ExportProof(proof, []string{"35"}, proof_out)

// vk: *groth16_bn254.VerifyingKey or *groth16_bls12381.VerifyingKey
var vk = getVK()
vk_out, _ := os.Create(VKeyPath)
err = gnarktosnarkjs.ExportVerifyingKey(vk, vk_out)

Both proof.json and vk.json are fully compatible with snarkjs, so you can directly use them with the snarkjs verify command.

Supported Curves

  • BN254
  • BLS12-381

License

MIT

About

Go library for exporting Groth16 proofs and verifying keys from gnark into snarkjs-compatible JSON (BN254, BLS12-381).

Topics

Resources

License

Stars

Watchers

Forks

Languages