gnark-crypto

module
v0.0.0-...-69a8e72 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: Apache-2.0

README

gnark-crypto

Twitter URL License Go Report Card PkgGoDev DOI

gnark-crypto provides efficient cryptographic primitives, in Go:

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

Warning

gnark-crypto is not fully 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.

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

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.17 and 1.18).

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).

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 field (generated by the gnark-crypto/field package). 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. Need to derive (mostly) identical code for various moduli and curves, with consistent APIs. Generics introduce significant performance overhead and are not yet suited for high performance computing.

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

go generate ./...

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.1,
  author       = {Gautam Botrel and
                  Thomas Piellard and
                  Youssef El Housni and
                  Arya Tabaie and
                  Ivo Kubjas},
  title        = {ConsenSys/gnark-crypto: v0.6.1},
  month        = feb,
  year         = 2022,
  publisher    = {Zenodo},
  version      = {v0.6.1},
  doi          = {10.5281/zenodo.6092968},
  url          = {https://doi.org/10.5281/zenodo.6092968}
}

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, bls12-378, bn254, bw6-761, bls24-315, bls24-317, bw6-633, bls12-378 and bw6-756 elliptic curves implementation (+pairing).
Package ecc provides bls12-381, bls12-377, bls12-378, bn254, bw6-761, bls24-315, bls24-317, bw6-633, bls12-378 and bw6-756 elliptic curves implementation (+pairing).
bls12-377
Package bls12377 efficient elliptic curve, pairing and hash to curve implementation for bls12-377.
Package bls12377 efficient elliptic curve, pairing and hash to curve 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/fri
Package fri provides the FRI (multiplicative) commitment scheme.
Package fri provides the FRI (multiplicative) commitment scheme.
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-378
Package bls12378 efficient elliptic curve, pairing and hash to curve implementation for bls12-378.
Package bls12378 efficient elliptic curve, pairing and hash to curve implementation for bls12-378.
bls12-378/fp
Package fp contains field arithmetic operations for modulus = 0x3eeb04...000001.
Package fp contains field arithmetic operations for modulus = 0x3eeb04...000001.
bls12-378/fr
Package fr contains field arithmetic operations for modulus = 0x20e7b9...000001.
Package fr contains field arithmetic operations for modulus = 0x20e7b9...000001.
bls12-378/fr/fft
Package fft provides in-place discrete Fourier transform.
Package fft provides in-place discrete Fourier transform.
bls12-378/fr/fri
Package fri provides the FRI (multiplicative) commitment scheme.
Package fri provides the FRI (multiplicative) commitment scheme.
bls12-378/fr/kzg
Package kzg provides a KZG commitment scheme.
Package kzg provides a KZG commitment scheme.
bls12-378/fr/mimc
Package mimc provides MiMC hash function using Miyaguchi–Preneel construction.
Package mimc provides MiMC hash function using Miyaguchi–Preneel construction.
bls12-378/fr/permutation
Package permutation provides an API to build permutation proofs.
Package permutation provides an API to build permutation proofs.
bls12-378/fr/plookup
Package plookup provides an API to build plookup proofs.
Package plookup provides an API to build plookup proofs.
bls12-378/fr/polynomial
Package polynomial provides polynomial methods and commitment schemes.
Package polynomial provides polynomial methods and commitment schemes.
bls12-378/twistededwards
Package twistededwards provides bls12-378's twisted edwards "companion curve" defined on fr.
Package twistededwards provides bls12-378's twisted edwards "companion curve" defined on fr.
bls12-378/twistededwards/eddsa
Package eddsa provides EdDSA signature scheme on bls12-378's twisted edwards curve.
Package eddsa provides EdDSA signature scheme on bls12-378's twisted edwards curve.
bls12-381
Package bls12381 efficient elliptic curve, pairing and hash to curve implementation for bls12-381.
Package bls12381 efficient elliptic curve, pairing and hash to curve implementation for bls12-381.
bls12-381/bandersnatch
Package bandersnatch provides bls12-381's twisted edwards "companion curve" defined on fr.
Package bandersnatch provides bls12-381's twisted edwards "companion curve" defined on fr.
bls12-381/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/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/fri
Package fri provides the FRI (multiplicative) commitment scheme.
Package fri provides the FRI (multiplicative) commitment scheme.
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/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, pairing and hash to curve implementation for bls24-315.
Package bls24315 efficient elliptic curve, pairing and hash to curve 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/fri
Package fri provides the FRI (multiplicative) commitment scheme.
Package fri provides the FRI (multiplicative) commitment scheme.
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.
bls24-317
Package bls24317 efficient elliptic curve, pairing and hash to curve implementation for bls24-317.
Package bls24317 efficient elliptic curve, pairing and hash to curve implementation for bls24-317.
bls24-317/fp
Package fp contains field arithmetic operations for modulus = 0x1058ca...ab2aab.
Package fp contains field arithmetic operations for modulus = 0x1058ca...ab2aab.
bls24-317/fr
Package fr contains field arithmetic operations for modulus = 0x443f91...000001.
Package fr contains field arithmetic operations for modulus = 0x443f91...000001.
bls24-317/fr/fft
Package fft provides in-place discrete Fourier transform.
Package fft provides in-place discrete Fourier transform.
bls24-317/fr/fri
Package fri provides the FRI (multiplicative) commitment scheme.
Package fri provides the FRI (multiplicative) commitment scheme.
bls24-317/fr/kzg
Package kzg provides a KZG commitment scheme.
Package kzg provides a KZG commitment scheme.
bls24-317/fr/mimc
Package mimc provides MiMC hash function using Miyaguchi–Preneel construction.
Package mimc provides MiMC hash function using Miyaguchi–Preneel construction.
bls24-317/fr/permutation
Package permutation provides an API to build permutation proofs.
Package permutation provides an API to build permutation proofs.
bls24-317/fr/plookup
Package plookup provides an API to build plookup proofs.
Package plookup provides an API to build plookup proofs.
bls24-317/fr/polynomial
Package polynomial provides polynomial methods and commitment schemes.
Package polynomial provides polynomial methods and commitment schemes.
bls24-317/twistededwards
Package twistededwards provides bls24-317's twisted edwards "companion curve" defined on fr.
Package twistededwards provides bls24-317's twisted edwards "companion curve" defined on fr.
bls24-317/twistededwards/eddsa
Package eddsa provides EdDSA signature scheme on bls24-317's twisted edwards curve.
Package eddsa provides EdDSA signature scheme on bls24-317's twisted edwards curve.
bn254
Package bn254 efficient elliptic curve, pairing and hash to curve implementation for bn254.
Package bn254 efficient elliptic curve, pairing and hash to curve 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/fri
Package fri provides the FRI (multiplicative) commitment scheme.
Package fri provides the FRI (multiplicative) commitment scheme.
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, pairing and hash to curve implementation for bw6-633.
Package bw6633 efficient elliptic curve, pairing and hash to curve 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/fri
Package fri provides the FRI (multiplicative) commitment scheme.
Package fri provides the FRI (multiplicative) commitment scheme.
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-756
Package bw6756 efficient elliptic curve, pairing and hash to curve implementation for bw6-756.
Package bw6756 efficient elliptic curve, pairing and hash to curve implementation for bw6-756.
bw6-756/fp
Package fp contains field arithmetic operations for modulus = 0xf76adb...000001.
Package fp contains field arithmetic operations for modulus = 0xf76adb...000001.
bw6-756/fr
Package fr contains field arithmetic operations for modulus = 0x3eeb04...000001.
Package fr contains field arithmetic operations for modulus = 0x3eeb04...000001.
bw6-756/fr/fft
Package fft provides in-place discrete Fourier transform.
Package fft provides in-place discrete Fourier transform.
bw6-756/fr/fri
Package fri provides the FRI (multiplicative) commitment scheme.
Package fri provides the FRI (multiplicative) commitment scheme.
bw6-756/fr/kzg
Package kzg provides a KZG commitment scheme.
Package kzg provides a KZG commitment scheme.
bw6-756/fr/mimc
Package mimc provides MiMC hash function using Miyaguchi–Preneel construction.
Package mimc provides MiMC hash function using Miyaguchi–Preneel construction.
bw6-756/fr/permutation
Package permutation provides an API to build permutation proofs.
Package permutation provides an API to build permutation proofs.
bw6-756/fr/plookup
Package plookup provides an API to build plookup proofs.
Package plookup provides an API to build plookup proofs.
bw6-756/fr/polynomial
Package polynomial provides polynomial methods and commitment schemes.
Package polynomial provides polynomial methods and commitment schemes.
bw6-756/twistededwards
Package twistededwards provides bw6-756's twisted edwards "companion curve" defined on fr.
Package twistededwards provides bw6-756's twisted edwards "companion curve" defined on fr.
bw6-756/twistededwards/eddsa
Package eddsa provides EdDSA signature scheme on bw6-756's twisted edwards curve.
Package eddsa provides EdDSA signature scheme on bw6-756's twisted edwards curve.
bw6-761
Package bw6761 efficient elliptic curve, pairing and hash to curve implementation for bw6-761.
Package bw6761 efficient elliptic curve, pairing and hash to curve 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/fri
Package fri provides the FRI (multiplicative) commitment scheme.
Package fri provides the FRI (multiplicative) commitment scheme.
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.
twistededwards
Package twistededwards define unique identifier for twited edwards curves implemented in gnark-crypto
Package twistededwards define unique identifier for twited edwards curves implemented in gnark-crypto
field
goff
Package goff (go finite field) is a library that generates fast field arithmetic code for a given modulus.
Package goff (go finite field) is a library that generates fast field arithmetic code for a given modulus.
goff/cmd
Package cmd is the CLI interface for goff
Package cmd is the CLI interface for goff
goldilocks
Package goldilocks contains field arithmetic operations for modulus = 0xffffff...000001.
Package goldilocks contains field arithmetic operations for modulus = 0xffffff...000001.
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
field
Package field provides Golang code generation for efficient field arithmetic operations.
Package field provides Golang code generation for efficient field arithmetic operations.
field/asm/amd64
Package amd64 contains syntactic sugar to generate amd64 assembly code
Package amd64 contains syntactic sugar to generate amd64 assembly code
field/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 kzg provides constructor for curved-typed KZG SRS
Package kzg provides constructor for curved-typed KZG SRS
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