• Stars
    star
    1,265
  • Rank 35,661 (Top 0.8 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created about 4 years ago
  • Updated 13 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

gnark is a fast zk-SNARK library that offers a high-level API to design circuits. The library is open source and developed under the Apache 2.0 license

gnark zk-SNARK library

Twitter URL License Go Report Card PkgGoDev Documentation Status DOI

gnark is a fast zk-SNARK library that offers a high-level API to design circuits. The library is open source and developed under the Apache 2.0 license

Useful Links

gnark Users

To get started with gnark and write your first circuit, follow these instructions.

Checkout the online playground to compile circuits and visualize constraint systems.

Warning

gnark has been partially audited and is provided as-is, we make no guarantees or warranties to its safety and reliability. In particular, gnark makes no security guarantees such as constant time implementation or side-channel attack resistance.

gnark and gnark-crypto packages are optimized for 64bits architectures (x86 amd64) and tested on Unix (Linux / macOS).

Issues

gnark issues are tracked in the GitHub issues tab.

To report a security bug, please refer to gnark Security Policy.

If you have any questions, queries or comments, GitHub discussions is the place to find us.

You can also get in touch directly: [email protected]

Release Notes

Release Notes

Proving schemes and curves

Refer to Proving schemes and curves for more details.

gnark support the following zk-SNARKs:

which can be instantiated with the following curves

  • BN254
  • BLS12-381
  • BLS12-377
  • BW6-761
  • BLS24-315
  • BW6-633
  • BLS24-317

Example

Refer to the gnark User Documentation

Here is what x**3 + x + 5 = y looks like

package main

import (
	"github.com/consensys/gnark-crypto/ecc"
	"github.com/consensys/gnark/backend/groth16"
	"github.com/consensys/gnark/frontend"
	"github.com/consensys/gnark/frontend/cs/r1cs"
)

// CubicCircuit defines a simple circuit
// x**3 + x + 5 == y
type CubicCircuit struct {
	// struct tags on a variable is optional
	// default uses variable name and secret visibility.
	X frontend.Variable `gnark:"x"`
	Y frontend.Variable `gnark:",public"`
}

// Define declares the circuit constraints
// x**3 + x + 5 == y
func (circuit *CubicCircuit) Define(api frontend.API) error {
	x3 := api.Mul(circuit.X, circuit.X, circuit.X)
	api.AssertIsEqual(circuit.Y, api.Add(x3, circuit.X, 5))
	return nil
}

func main() {
	// compiles our circuit into a R1CS
	var circuit CubicCircuit
	ccs, _ := frontend.Compile(ecc.BN254.ScalarField(), r1cs.NewBuilder, &circuit)

	// groth16 zkSNARK: Setup
	pk, vk, _ := groth16.Setup(ccs)

	// witness definition
	assignment := CubicCircuit{X: 3, Y: 35}
	witness, _ := frontend.NewWitness(&assignment, ecc.BN254.ScalarField())
	publicWitness, _ := witness.Public()

	// groth16: Prove & Verify
	proof, _ := groth16.Prove(ccs, pk, witness)
	groth16.Verify(proof, vk, publicWitness)
}

GPU Support

Icicle Library

The following schemes and curves support experimental use of Ingomyama's Icicle GPU library for low level zk-SNARK primitives such as MSM, NTT, and polynomial operations:

instantiated with the following curve(s)

  • BN254

To use GPUs, add the icicle buildtag to your build/run commands, e.g. go run -tags=icicle main.go.

You can then toggle on or off icicle acceleration by providing the WithIcicleAcceleration backend ProverOption:

    // toggle on
    proofIci, err := groth16.Prove(ccs, pk, secretWitness, backend.WithIcicleAcceleration())
    
    // toggle off
    proof, err := groth16.Prove(ccs, pk, secretWitness)

For more information about prerequisites see the Icicle repo.

Citing

If you use gnark in your research a citation would be appreciated. Please use the following BibTeX to cite the most recent release.

@software{gnark-v0.9.0,
  author       = {Gautam Botrel and
                  Thomas Piellard and
                  Youssef El Housni and
                  Ivo Kubjas and
                  Arya Tabaie},
  title        = {ConsenSys/gnark: v0.9.0},
  month        = feb,
  year         = 2023,
  publisher    = {Zenodo},
  version      = {v0.9.0},
  doi          = {10.5281/zenodo.5819104},
  url          = {https://doi.org/10.5281/zenodo.5819104}
}

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

This project is licensed under the Apache 2 License - see the LICENSE file for details

More Repositories

1

smart-contract-best-practices

A guide to smart contract security best practices
HTML
7,296
star
2

ethereum-developer-tools-list

A guide to available tools and platforms for developing on Ethereum.
5,172
star
3

quorum

A permissioned implementation of Ethereum supporting data privacy
Go
4,581
star
4

mythril

Security analysis tool for EVM bytecode. Supports smart contracts built for Ethereum, Hedera, Quorum, Vechain, Roostock, Tron and other EVM-compatible blockchains.
Python
3,683
star
5

Tokens

Ethereum Token Contracts
JavaScript
2,020
star
6

eth-lightwallet

Lightweight JS Wallet for Node and the browser
JavaScript
1,418
star
7

surya

A set of utilities for exploring Solidity contracts
JavaScript
1,027
star
8

ethql

A GraphQL interface to Ethereum ๐Ÿ”ฅ
TypeScript
622
star
9

abi-decoder

Nodejs and Javascript library for decoding data params and events from ethereum transactions
JavaScript
605
star
10

vscode-solidity-auditor

Solidity language support and visual security auditor for Visual Studio Code
JavaScript
560
star
11

teku

Java Implementation of the Ethereum 2.0 Beacon Chain
Java
557
star
12

cakeshop

An integrated development environment and SDK for Ethereum-like ledgers
JavaScript
510
star
13

Token-Factory

Basic Token Factory dapp.
JavaScript
475
star
14

gnark-crypto

gnark-crypto provides elliptic curve and pairing-based cryptography on BN, BLS12, BLS24 and BW6 curves. It also provides various algorithms (algebra, crypto) of particular interest to zero knowledge proof systems.
Go
452
star
15

constellation

Peer-to-peer encrypted message exchange
Haskell
379
star
16

UniversalToken

Implementation of Universal Token for Assets and Payments
JavaScript
336
star
17

quorum-examples

Examples for Quorum
Shell
316
star
18

scribble

Scribble instrumentation tool
TypeScript
310
star
19

anonymous-zether

A private payment system for Ethereum-based blockchains, with no trusted setup.
Solidity
283
star
20

defi-score

DeFi Score: An open framework for evaluating DeFi protocols
Python
279
star
21

EthOn

EthOn - The Ethereum Ontology
HTML
245
star
22

Mahuta

IPFS Storage service with search capability
Java
230
star
23

doc.zk-evm

Linea documentation
JavaScript
224
star
24

solidity-metrics

Solidity Code Metrics
JavaScript
207
star
25

tessera

Tessera - Enterprise Implementation of Quorum's transaction manager
Java
169
star
26

PLCRVoting

Partial Lock Commit Reveal Voting System that utilizes ERC20 Tokens
JavaScript
169
star
27

ethjsonrpc

Python JSON-RPC client for the Ethereum blockchain
Python
155
star
28

zero-knowledge-proofs

Zero Knowledge Proofs and how they can be implemented in Quorum
C++
128
star
29

python-solidity-parser

An experimental Solidity parser for Python built on top of a robust ANTLR4 grammar ๐Ÿ“š
Python
125
star
30

truffle-security

MythX smart contract security verification plugin for Truffle Framework
JavaScript
124
star
31

web3signer

Web3Signer is an open-source signing service capable of signing on multiple platforms (Ethereum1 and 2, Filecoin) using private keys stored in an external vault, or encrypted on a disk.
Java
122
star
32

btcrelay-fetchd

Just the fetchd script of btcrelay
Python
116
star
33

evm-dafny

An EVM interpreter in Dafny
Dafny
113
star
34

ethereum-dissectors

๐Ÿ”Wireshark dissectors for Ethereum devp2p protocols
C
109
star
35

quorum-dev-quickstart

The Quorum Developer Quickstart utility can be used to rapidly generate local Quorum blockchain networks for development and demo purposes using Besu, GoQuorum, and Codefi Orchestrate.
Solidity
108
star
36

ethsigner

A transaction signing application to be used with a web3 provider.
Java
107
star
37

daedaluzz

Benchmark Generator for Smart-Contract Fuzzers
Solidity
106
star
38

solc-typed-ast

A TypeScript package providing a normalized typed Solidity AST along with the utilities necessary to generate the AST (from Solc) and traverse/manipulate it.
TypeScript
105
star
39

truffle-webpack-demo

A demo Webpack + React App using truffle-solidity-loader
JavaScript
95
star
40

orion

Orion is a PegaSys component for doing private transactions
Java
92
star
41

blockchainSecurityDB

JavaScript
88
star
42

quorum-kubernetes

Helm charts for Hyperledger Besu and GoQuorum
Mustache
85
star
43

gpact

General Purpose Atomic Crosschain Transaction Protocol
Java
84
star
44

quorum-docs

Documentation assets for Quorum
84
star
45

mythx-cli

A command line interface for the MythX smart contract security analysis API
Python
81
star
46

bytecode-verifier

Compile Solidity source code and verify its bytecode matches the blockchain
JavaScript
80
star
47

linea-attestation-registry

Verax is a shared registry for storing attestations of public interest on EVM chains, designed to enhance data discoverability and consumption for dApps across the network.
TypeScript
78
star
48

goff

goff (go finite field) is a unix-like tool that generates fast field arithmetic in Go.
Go
76
star
49

zsl-q

ZSL on Quorum
C++
71
star
50

security-workshop-for-devs

Secure smart contract development workshop hosted by ConsenSys Diligence and MythX.
70
star
51

Legions

Ethereum/EVM Node Security Toolkit
Python
69
star
52

eth2.0-dafny

Eth2.0 spec in Dafny
Dafny
67
star
53

starknet-snap

The MetaMask Snap for Starknet
TypeScript
65
star
54

quorum-docker-Nnodes

Run a bunch of Quorum nodes, each in a separate Docker container.
Shell
65
star
55

Project-Alchemy

Ethereum-Zcash Integration effort
63
star
56

handel

Multi-Signature Aggregation in a Large Byzantine Committees
Go
52
star
57

qubernetes

Quorum on Kubernetes.
Go
52
star
58

Uniswap-audit-report-2018-12

50
star
59

quorum-tools

Tools for running Quorum clusters and integration tests
Haskell
50
star
60

doc.teku

ConsenSys Ethereum 2.0 client
CSS
47
star
61

vscode-solidity-metrics

Generate Solidity Source Code Metrics, Complexity and Risk profile reports for your project.
JavaScript
46
star
62

private-networks-deployment-scripts

This repository contains out-of-the-box deployment scripts for private PoA networks
Shell
45
star
63

awesome-quorum

A curated list of awesome softwares, libraries, tools, articles, educational resources, discussion channels and more to build on ConsenSys Quorum.
45
star
64

wittgenstein

Simulator for some PoS or consensus algorithms. Includes dfinity, casper IMD and others
Java
45
star
65

vscode-ethover

Ethereum Account Address Hover Info and Actions
JavaScript
42
star
66

permissioning-smart-contracts

Smart contracts for the Besu permissioning system
TypeScript
41
star
67

besu-sample-networks

Hyperledger Besu Ethereum client quick-start makes you able to simply test all Besu features.
40
star
68

0x-review

Security review of 0x smart contracts
HTML
39
star
69

mythx-playground

Exercises to go along with smart contract security workshops by MythX and ConsenSys Diligence
Solidity
39
star
70

linea-tutorials

An EVM-equivalent zk-rollup for scaling Ethereum dapps
Shell
38
star
71

kubernetes-action

GitHub Action to run kubectl
Dockerfile
38
star
72

evm-analyzer-benchmark-suite

A benchmark suite for evaluating the precision of EVM code analysis tools.
HTML
38
star
73

quorum-key-manager

A universal Key & Account Management solution for blockchain applications.
Go
37
star
74

quorum-cloud

Deploy Quorum network in a cloud provider of choice
HCL
36
star
75

quorum.js

Quorum.js is an extension to web3.js providing support for JP Morgan's Quorum API
JavaScript
36
star
76

web3js-eea

EEA JavaScript libraries.
JavaScript
35
star
77

truffle-solidity-loader

A Webpack loader that will parse and provision Solidity files to Javascript using Truffle for compilation
JavaScript
35
star
78

rimble-app-demo

React Ethereum dApp demonstrating onboarding and transaction UX
JavaScript
35
star
79

secureum-diligence-bootcamp

Solidity
34
star
80

linea-contracts

Linea smart-contracts
Solidity
33
star
81

pythx

A Python library for the MythX smart contract security analysis platform
Python
33
star
82

react-metamask

JavaScript
32
star
83

infura-sdk

Infura NFT SDK
TypeScript
32
star
84

diligence-fuzzing

Python
32
star
85

quorum-aws

Tools for deploying Quorum clusters to AWS
HCL
32
star
86

web3studio-soy

Static Websites on the Distributed Web
JavaScript
31
star
87

boilerplate-react

React app boilerplate by ConsenSys France
JavaScript
29
star
88

hellhound

HellHound is a decentralized blind computation platform.
Go
29
star
89

aragraph

Visualize your Aragon DAO Templates
JavaScript
29
star
90

quorum-wizard

Quorum Wizard is a command line tool that allow users to set up a development Quorum network on their local machine in less than 2 minutes.
JavaScript
28
star
91

doc.goquorum

Documentation site for GoQuorum, the ConsenSys Enterprise Ethereum client
CSS
27
star
92

mythxjs

TypeScript
26
star
93

linea-token-list

Linea Token List
TypeScript
25
star
94

web3js-quorum

JavaScript
24
star
95

0x_audit_report_2018-07-23

0x Protocol v2 Audit
HTML
24
star
96

hackathon-2021-dapp-workshop

JavaScript
24
star
97

so101_canon

Resources on self-management/organization
24
star
98

quorum-explorer

A light-weight front-end explorer for Besu and GoQuorum to visualise private networks and deploy smart contracts
TypeScript
24
star
99

sidechains-samples

Sample code for Atomic Crosschain Transactions
Java
22
star
100

deposit-sc-dafny

Deposit smart contract in Dafny
Dafny
20
star