gnark-crypto

module
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2022 License: Apache-2.0

README

gnark-crypto

License Go Report Card PkgGoDev DOI

gnark-crypto provides:

gnark-crypto is actively developed and maintained by the team (gnark@consensys.net | HackMD) behind:

Warning

gnark-crypto has not been audited and is provided as-is, use at your own risk. In particular, gnark-crypto makes no security guarantees such as constant time implementation or side-channel attack resistance.

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

Getting started

Go version

gnark-crypto is tested with the last 2 major releases of Go (1.16 and 1.17).

Install gnark-crypto
go get github.com/consensys/gnark-crypto

Note if that if you use go modules, in go.mod the module path is case sensitive (use consensys and not ConsenSys).

Documentation

PkgGoDev

The APIs are consistent accross the curves. For example, here is bn254 godoc.

Development

Most (but not all) of the code is generated from the templates in internal/generator.

The generated code contains little to no interfaces and is strongly typed with a base field (generated by the gnark-crypto/field). The two main factors driving this design choice are:

  1. Performance: gnark-crypto algorithms manipulates millions (if not billions) of field elements. Interface indirection at this level, plus garbage collection indexing takes a heavy toll on perf.
  2. No generics in Go: need to derive (mostly) identical code for various moduli and curves, with consistent APIs

To regenerate the files, see internal/generator/main.go. Run:

go generate ./internal/...

Benchmarks

Benchmarking pairing-friendly elliptic curves libraries

The libraries are implemented in different languages and some use more assembly code than others. Besides the different algorithmic and software optimizations used across, it should be noted also that some libraries target constant-time implementation for some operations making it de facto slower. However, it can be clear that consensys/gnark-crypto is one of the fastest pairing-friendly elliptic curve libraries to be used in zkp projects with different curves.

Citing

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

@software{gnark-crypto-v0.6,
  author       = {Gautam Botrel and
                  Thomas Piellard and
                  Youssef El Housni and
                  Arya Tabaie and
                  Ivo Kubjas},
  title        = {ConsenSys/gnark-crypto: v0.6.0},
  month        = jan,
  year         = 2022,
  publisher    = {Zenodo},
  version      = {v0.6.0},
  doi          = {10.5281/zenodo.5815454},
  url          = {https://doi.org/10.5281/zenodo.5815454}
}

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

Directories

Path Synopsis
accumulator
merkletree
Package merkletree provides Merkle tree and proof following RFC 6962.
Package merkletree provides Merkle tree and proof following RFC 6962.
ecc
Package ecc provides bls12-381, bls12-377, bn254, bw6-761, bls24-315 and bw6-633 elliptic curves implementation (+pairing).
Package ecc provides bls12-381, bls12-377, bn254, bw6-761, bls24-315 and bw6-633 elliptic curves implementation (+pairing).
bls12-377
Package bls12377 efficient elliptic curve and pairing implementation for bls12-377.
Package bls12377 efficient elliptic curve and pairing implementation for bls12-377.
bls12-377/fp
Package fp contains field arithmetic operations for modulus = 0x1ae3a4...000001.
Package fp contains field arithmetic operations for modulus = 0x1ae3a4...000001.
bls12-377/fr
Package fr contains field arithmetic operations for modulus = 0x12ab65...000001.
Package fr contains field arithmetic operations for modulus = 0x12ab65...000001.
bls12-377/fr/fft
Package fft provides in-place discrete Fourier transform.
Package fft provides in-place discrete Fourier transform.
bls12-377/fr/kzg
Package kzg provides a KZG commitment scheme.
Package kzg provides a KZG commitment scheme.
bls12-377/fr/mimc
Package mimc provides MiMC hash function using Miyaguchi–Preneel construction.
Package mimc provides MiMC hash function using Miyaguchi–Preneel construction.
bls12-377/fr/permutation
Package permutation provides an API to build permutation proofs.
Package permutation provides an API to build permutation proofs.
bls12-377/fr/plookup
Package plookup provides an API to build plookup proofs.
Package plookup provides an API to build plookup proofs.
bls12-377/fr/polynomial
Package polynomial provides polynomial methods and commitment schemes.
Package polynomial provides polynomial methods and commitment schemes.
bls12-377/twistededwards
Package twistededwards provides bls12-377's twisted edwards "companion curve" defined on fr.
Package twistededwards provides bls12-377's twisted edwards "companion curve" defined on fr.
bls12-377/twistededwards/eddsa
Package eddsa provides EdDSA signature scheme on bls12-377's twisted edwards curve.
Package eddsa provides EdDSA signature scheme on bls12-377's twisted edwards curve.
bls12-381
Package bls12381 efficient elliptic curve and pairing implementation for bls12-381.
Package bls12381 efficient elliptic curve and pairing implementation for bls12-381.
bls12-381/fp
Package fp contains field arithmetic operations for modulus = 0x1a0111...ffaaab.
Package fp contains field arithmetic operations for modulus = 0x1a0111...ffaaab.
bls12-381/fr
Package fr contains field arithmetic operations for modulus = 0x73eda7...000001.
Package fr contains field arithmetic operations for modulus = 0x73eda7...000001.
bls12-381/fr/fft
Package fft provides in-place discrete Fourier transform.
Package fft provides in-place discrete Fourier transform.
bls12-381/fr/kzg
Package kzg provides a KZG commitment scheme.
Package kzg provides a KZG commitment scheme.
bls12-381/fr/mimc
Package mimc provides MiMC hash function using Miyaguchi–Preneel construction.
Package mimc provides MiMC hash function using Miyaguchi–Preneel construction.
bls12-381/fr/permutation
Package permutation provides an API to build permutation proofs.
Package permutation provides an API to build permutation proofs.
bls12-381/fr/plookup
Package plookup provides an API to build plookup proofs.
Package plookup provides an API to build plookup proofs.
bls12-381/fr/polynomial
Package polynomial provides polynomial methods and commitment schemes.
Package polynomial provides polynomial methods and commitment schemes.
bls12-381/twistededwards
Package twistededwards provides bls12-381's twisted edwards "companion curve" defined on fr.
Package twistededwards provides bls12-381's twisted edwards "companion curve" defined on fr.
bls12-381/twistededwards/bandersnatch
Package bandersnatch provides bls12-381's twisted edwards "companion curve" defined on fr with efficient enodomorphism.
Package bandersnatch provides bls12-381's twisted edwards "companion curve" defined on fr with efficient enodomorphism.
bls12-381/twistededwards/bandersnatch/eddsa
Package eddsa provides EdDSA signature scheme on bls12-381's twisted edwards curve.
Package eddsa provides EdDSA signature scheme on bls12-381's twisted edwards curve.
bls12-381/twistededwards/eddsa
Package eddsa provides EdDSA signature scheme on bls12-381's twisted edwards curve.
Package eddsa provides EdDSA signature scheme on bls12-381's twisted edwards curve.
bls24-315
Package bls24315 efficient elliptic curve and pairing implementation for bls24-315.
Package bls24315 efficient elliptic curve and pairing implementation for bls24-315.
bls24-315/fp
Package fp contains field arithmetic operations for modulus = 0x4c23a0...300001.
Package fp contains field arithmetic operations for modulus = 0x4c23a0...300001.
bls24-315/fr
Package fr contains field arithmetic operations for modulus = 0x196dea...c00001.
Package fr contains field arithmetic operations for modulus = 0x196dea...c00001.
bls24-315/fr/fft
Package fft provides in-place discrete Fourier transform.
Package fft provides in-place discrete Fourier transform.
bls24-315/fr/kzg
Package kzg provides a KZG commitment scheme.
Package kzg provides a KZG commitment scheme.
bls24-315/fr/mimc
Package mimc provides MiMC hash function using Miyaguchi–Preneel construction.
Package mimc provides MiMC hash function using Miyaguchi–Preneel construction.
bls24-315/fr/permutation
Package permutation provides an API to build permutation proofs.
Package permutation provides an API to build permutation proofs.
bls24-315/fr/plookup
Package plookup provides an API to build plookup proofs.
Package plookup provides an API to build plookup proofs.
bls24-315/fr/polynomial
Package polynomial provides polynomial methods and commitment schemes.
Package polynomial provides polynomial methods and commitment schemes.
bls24-315/twistededwards
Package twistededwards provides bls24-315's twisted edwards "companion curve" defined on fr.
Package twistededwards provides bls24-315's twisted edwards "companion curve" defined on fr.
bls24-315/twistededwards/eddsa
Package eddsa provides EdDSA signature scheme on bls24-315's twisted edwards curve.
Package eddsa provides EdDSA signature scheme on bls24-315's twisted edwards curve.
bn254
Package bn254 efficient elliptic curve and pairing implementation for bn254.
Package bn254 efficient elliptic curve and pairing implementation for bn254.
bn254/fp
Package fp contains field arithmetic operations for modulus = 0x30644e...7cfd47.
Package fp contains field arithmetic operations for modulus = 0x30644e...7cfd47.
bn254/fr
Package fr contains field arithmetic operations for modulus = 0x30644e...000001.
Package fr contains field arithmetic operations for modulus = 0x30644e...000001.
bn254/fr/fft
Package fft provides in-place discrete Fourier transform.
Package fft provides in-place discrete Fourier transform.
bn254/fr/kzg
Package kzg provides a KZG commitment scheme.
Package kzg provides a KZG commitment scheme.
bn254/fr/mimc
Package mimc provides MiMC hash function using Miyaguchi–Preneel construction.
Package mimc provides MiMC hash function using Miyaguchi–Preneel construction.
bn254/fr/permutation
Package permutation provides an API to build permutation proofs.
Package permutation provides an API to build permutation proofs.
bn254/fr/plookup
Package plookup provides an API to build plookup proofs.
Package plookup provides an API to build plookup proofs.
bn254/fr/polynomial
Package polynomial provides polynomial methods and commitment schemes.
Package polynomial provides polynomial methods and commitment schemes.
bn254/twistededwards
Package twistededwards provides bn254's twisted edwards "companion curve" defined on fr.
Package twistededwards provides bn254's twisted edwards "companion curve" defined on fr.
bn254/twistededwards/eddsa
Package eddsa provides EdDSA signature scheme on bn254's twisted edwards curve.
Package eddsa provides EdDSA signature scheme on bn254's twisted edwards curve.
bw6-633
Package bw6633 efficient elliptic curve and pairing implementation for bw6-633.
Package bw6633 efficient elliptic curve and pairing implementation for bw6-633.
bw6-633/fp
Package fp contains field arithmetic operations for modulus = 0x126633...70000d.
Package fp contains field arithmetic operations for modulus = 0x126633...70000d.
bw6-633/fr
Package fr contains field arithmetic operations for modulus = 0x4c23a0...300001.
Package fr contains field arithmetic operations for modulus = 0x4c23a0...300001.
bw6-633/fr/fft
Package fft provides in-place discrete Fourier transform.
Package fft provides in-place discrete Fourier transform.
bw6-633/fr/kzg
Package kzg provides a KZG commitment scheme.
Package kzg provides a KZG commitment scheme.
bw6-633/fr/mimc
Package mimc provides MiMC hash function using Miyaguchi–Preneel construction.
Package mimc provides MiMC hash function using Miyaguchi–Preneel construction.
bw6-633/fr/permutation
Package permutation provides an API to build permutation proofs.
Package permutation provides an API to build permutation proofs.
bw6-633/fr/plookup
Package plookup provides an API to build plookup proofs.
Package plookup provides an API to build plookup proofs.
bw6-633/fr/polynomial
Package polynomial provides polynomial methods and commitment schemes.
Package polynomial provides polynomial methods and commitment schemes.
bw6-633/twistededwards
Package twistededwards provides bw6-633's twisted edwards "companion curve" defined on fr.
Package twistededwards provides bw6-633's twisted edwards "companion curve" defined on fr.
bw6-633/twistededwards/eddsa
Package eddsa provides EdDSA signature scheme on bw6-633's twisted edwards curve.
Package eddsa provides EdDSA signature scheme on bw6-633's twisted edwards curve.
bw6-761
Package bw6761 efficient elliptic curve and pairing implementation for bw6-761.
Package bw6761 efficient elliptic curve and pairing implementation for bw6-761.
bw6-761/fp
Package fp contains field arithmetic operations for modulus = 0x122e82...00008b.
Package fp contains field arithmetic operations for modulus = 0x122e82...00008b.
bw6-761/fr
Package fr contains field arithmetic operations for modulus = 0x1ae3a4...000001.
Package fr contains field arithmetic operations for modulus = 0x1ae3a4...000001.
bw6-761/fr/fft
Package fft provides in-place discrete Fourier transform.
Package fft provides in-place discrete Fourier transform.
bw6-761/fr/kzg
Package kzg provides a KZG commitment scheme.
Package kzg provides a KZG commitment scheme.
bw6-761/fr/mimc
Package mimc provides MiMC hash function using Miyaguchi–Preneel construction.
Package mimc provides MiMC hash function using Miyaguchi–Preneel construction.
bw6-761/fr/permutation
Package permutation provides an API to build permutation proofs.
Package permutation provides an API to build permutation proofs.
bw6-761/fr/plookup
Package plookup provides an API to build plookup proofs.
Package plookup provides an API to build plookup proofs.
bw6-761/fr/polynomial
Package polynomial provides polynomial methods and commitment schemes.
Package polynomial provides polynomial methods and commitment schemes.
bw6-761/twistededwards
Package twistededwards provides bw6-761's twisted edwards "companion curve" defined on fr.
Package twistededwards provides bw6-761's twisted edwards "companion curve" defined on fr.
bw6-761/twistededwards/eddsa
Package eddsa provides EdDSA signature scheme on bw6-761's twisted edwards curve.
Package eddsa provides EdDSA signature scheme on bw6-761's twisted edwards curve.
Package field provides Golang code generation for efficient field arithmetic operations.
Package field provides Golang code generation for efficient field arithmetic operations.
asm/amd64
Package amd64 contains syntactic sugar to generate amd64 assembly code
Package amd64 contains syntactic sugar to generate amd64 assembly code
internal/addchain
Package addchain is derived from github.com/mmcloughlin/addchain internal packages or examples
Package addchain is derived from github.com/mmcloughlin/addchain internal packages or examples
Package hash provides MiMC hash function defined over curves implemented in gnark-crypto/ecc.
Package hash provides MiMC hash function defined over curves implemented in gnark-crypto/ecc.
internal
Package kzg provides constructor for curved-typed KZG SRS For more details, see ecc/XXX/fr/kzg package
Package kzg provides constructor for curved-typed KZG SRS For more details, see ecc/XXX/fr/kzg package
Package signature defines interfaces for a Signer and a PublicKey similarly to go/crypto standard package.
Package signature defines interfaces for a Signer and a PublicKey similarly to go/crypto standard package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL