github.com/consensys/gnark-crypto@v0.14.0/README.md (about)

     1  # gnark-crypto
     2  
     3  [![Twitter URL](https://img.shields.io/twitter/url/https/twitter.com/gnark_team.svg?style=social&label=Follow%20%40gnark_team)](https://twitter.com/gnark_team) [![License](https://img.shields.io/badge/license-Apache%202-blue)](LICENSE)  [![Go Report Card](https://goreportcard.com/badge/github.com/ConsenSys/gnark-crypto)](https://goreportcard.com/badge/github.com/ConsenSys/gnark-crypto) [![PkgGoDev](https://pkg.go.dev/badge/mod/github.com/consensys/gnark-crypto)](https://pkg.go.dev/mod/github.com/consensys/gnark-crypto) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5815453.svg)](https://doi.org/10.5281/zenodo.5815453)
     4  
     5  `gnark-crypto` provides efficient cryptographic primitives, in Go:
     6  
     7  * Elliptic curve cryptography & **Pairing** on:
     8    * [`bn254`] ([audit report](audit_oct2022.pdf))
     9    * [`bls12-381`] ([audit report](audit_oct2022.pdf))
    10    * [`bls24-317`]
    11    * [`bls12-377`] / [`bw6-761`]
    12    * [`bls24-315`] / [`bw6-633`]
    13    * [`bls12-378`] / [`bw6-756`]
    14    * Each of these curves has a [`twistededwards`] sub-package with its companion curve which allow efficient elliptic curve cryptography inside zkSNARK circuits.
    15  * [`field/goff`] - Finite field arithmetic code generator (blazingly fast big.Int)
    16  * [`fft`] - Fast Fourier Transform
    17  * [`fri`] - FRI (multiplicative) commitment scheme
    18  * [`fiatshamir`] - Fiat-Shamir transcript builder
    19  * [`mimc`] - MiMC hash function using Miyaguchi-Preneel construction
    20  * [`kzg`] - KZG commitment scheme
    21  * [`permutation`] - Permutation proofs
    22  * [`plookup`] - Plookup proofs
    23  * [`eddsa`] - EdDSA signatures (on the companion [`twistededwards`] curves)
    24  
    25  `gnark-crypto` is actively developed and maintained by the team (gnark@consensys.net | [HackMD](https://hackmd.io/@gnark)) behind:
    26  
    27  * [`gnark`: a framework to execute (and verify) algorithms in zero-knowledge](https://github.com/consensys/gnark)
    28  
    29  ## Warning
    30  
    31  **`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.**
    32  
    33  **To report a security bug, please refer to [`gnark` Security Policy](https://github.com/ConsenSys/gnark/blob/master/SECURITY.md).**
    34  
    35  `gnark-crypto` packages are optimized for 64bits architectures (x86 `amd64`) and tested on Unix (Linux / macOS).
    36  
    37  ## Getting started
    38  
    39  ### Go version
    40  
    41  `gnark-crypto` is tested with the last 2 major releases of Go (currently 1.19 and 1.20).
    42  
    43  ### Install `gnark-crypto`
    44  
    45  ```bash
    46  go get github.com/consensys/gnark-crypto
    47  ```
    48  
    49  Note that if you use go modules, in `go.mod` the module path is case sensitive (use `consensys` and not `ConsenSys`).
    50  
    51  ### Development
    52  
    53  Most (but not all) of the code is generated from the templates in `internal/generator`.
    54  
    55  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:
    56  
    57  1. Performance: `gnark-crypto` algorithms manipulate millions (if not billions) of field elements. Interface indirection at this level, plus garbage collection indexing takes a heavy toll on perf.
    58  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.
    59  
    60  To regenerate the files, see `internal/generator/main.go`. Run:
    61  
    62  ```bash
    63  go generate ./...
    64  ```
    65  
    66  ## Benchmarks
    67  
    68  [Benchmarking pairing-friendly elliptic curves libraries](https://hackmd.io/@gnark/eccbench)
    69  
    70  >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.
    71  
    72  ## Citing
    73  
    74  If you use `gnark-crypto` in your research a citation would be appreciated.
    75  Please use the following BibTeX to cite the most recent release.
    76  
    77  ```bib
    78  @software{gnark-crypto-v0.11.2,
    79    author       = {Gautam Botrel and
    80                    Thomas Piellard and
    81                    Youssef El Housni and
    82                    Arya Tabaie and
    83                    Gus Gutoski and
    84                    Ivo Kubjas},
    85    title        = {ConsenSys/gnark-crypto: v0.11.2},
    86    month        = jan,
    87    year         = 2023,
    88    publisher    = {Zenodo},
    89    version      = {v0.11.2},
    90    doi          = {10.5281/zenodo.5815453},
    91    url          = {https://doi.org/10.5281/zenodo.5815453}
    92  }
    93  ```
    94  
    95  ## Versioning
    96  
    97  We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/consensys/gnark-crypto/tags).
    98  
    99  ## License
   100  
   101  This project is licensed under the Apache 2 License - see the [LICENSE](LICENSE) file for details.
   102  
   103  [`field/goff`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/field/goff
   104  [`bn254`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bn254
   105  [`bls12-381`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bls12-381
   106  [`bls24-317`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bls24-317
   107  [`bls12-377`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bls12-377
   108  [`bls24-315`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bls24-315
   109  [`bls12-378`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bls12-378
   110  [`bw6-761`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bw6-761
   111  [`bw6-633`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bw6-633
   112  [`bw6-756`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bw6-756
   113  [`twistededwards`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bn254/twistededwards
   114  [`eddsa`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bn254/twistededwards/eddsa
   115  [`fft`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bn254/fr/fft
   116  [`fri`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bn254/fr/fri
   117  [`mimc`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bn254/fr/mimc
   118  [`kzg`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bn254/fr/kzg
   119  [`plookup`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bn254/fr/plookup
   120  [`permutation`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bn254/fr/permutation
   121  [`fiatshamir`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/fiat-shamir