GithubHelp home page GithubHelp logo

cryptopunkchina / gnark-crypto Goto Github PK

View Code? Open in Web Editor NEW

This project forked from consensys/gnark-crypto

0.0 0.0 0.0 11.8 MB

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.

License: Apache License 2.0

Go 44.38% Assembly 55.62%

gnark-crypto's Introduction

gnark-crypto

Twitter URL License Go Report Card PkgGoDev DOI

gnark-crypto provides:

  • Elliptic curve cryptography (+pairing) on BN254, BLS12-381, BLS12-377, BW6-761, BLS24-315, BW6-633, BLS12-378 and BW6-756
  • Finite field arithmetic (fast big.Int)
  • FFT
  • Polynomial commitment schemes
  • MiMC
  • EdDSA (on the "companion" twisted edwards curves)

gnark-crypto is actively developed and maintained by the team ([email protected] | 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.

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

gnark-crypto's People

Contributors

gbotrel avatar yelhousni avatar thomaspiellard avatar tabaie avatar ggutoski avatar zhiqiangxu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.