Coder Social home page Coder Social logo

rajeshrk18 / lambdaworks Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lambdaclass/lambdaworks

0.0 0.0 0.0 18.77 MB

The library for kids who wanna learn how to do SNARKs and learn other cryptographic stuff too

Home Page: https://lambdaclass.github.io/lambdaworks/

License: Apache License 2.0

C 0.01% Rust 97.54% Cuda 0.80% Nix 0.01% Makefile 0.21% Metal 1.09% Dockerfile 0.01% Cairo 0.33%

lambdaworks's Introduction

lambdaworks

From the heights of these towers of fields, forty centuries of mathematics look down on us.

This library provides efficient implementation of cryptographic primitives used to build proving systems. Along with it, many backends for proving systems are shipped, and compatibility with different frontends is supported.

Telegram Chat codecov

Main crates

Crypto

Most of math and crypto crates supports no-std without allocation with no-default-features. A few functions and modules require the alloc feature.

Both Math and Crypto support wasm with target wasm32-unknown-unknown. To see an example of how to use this to deploy a verifier in a browser, check the Cairo Prover wasm-pack verifier.

Examples - mini apps

Exercises and Challenges

Citing lambdaworks

If you use lambdaworks libraries in your research projects, please cite them using the following template:

@software{lambdaworks,
  author={lambdaworks contributors},
  title={lambdaworks},
  url={https://github.com/lambdaclass/lambdaworks},
  year={2023}
}

Why we built lambdaworks

Zero-Knowledge and Validity Proofs have gained a lot of attention over the last few years. We strongly believe in this potential and that is why we decided to start working in this challenging ecosystem, where math, cryptography and distributed systems meet. The main barrier in the beginning was not the cryptography or math but the lack of good libraries which are performant and developer friendly. There are some exceptions, though, like gnark or halo2. Some have nice APIs and are easy to work with, but they are not written in Rust, and some are written in Rust but have poor programming and engineering practices. Most of them don't have support for CUDA, Metal and WebGPU or distributed FFT calculation using schedulers like Dask.

So, we decided to build our library, focusing on performance, with clear documentation and developer-focused. Our core team is a group of passionate people from different backgrounds and different strengths; we think that the whole is greater than just the addition of the parts. We don't want to be a compilation of every research result in the ZK space. We want this to be a library that can be used in production, not just in academic research. We want to offer developers the main building blocks and proof systems so that they can build their applications on top of this library.

List of features

Disclaimer: This list contains cryptographic primitives and mathematical structures that we want to support in lambdaworks. It can be expanded later to include new primitives. If you find there is a mistake or there has been an update in another library, please let us know.

List of symbols:

  • โœ”๏ธ means the feature is currently supported.
  • ๐Ÿ—๏ธ means that the feature is partially implemented or is under active construction.
  • โŒ means that the feature is not currently supported.
Finite Fields Lambdaworks Arkworks Halo2 gnark Constantine
StarkField 252 โœ”๏ธ โœ”๏ธ โŒ โœ”๏ธ โŒ
Mersenne 31 โœ”๏ธ โŒ โŒ โŒ โŒ
Baby Bear โœ”๏ธ โŒ โŒ โŒ โŒ
MiniGoldilocks โœ”๏ธ โŒ โŒ โœ”๏ธ โŒ
ZK friendly Hash function Lambdaworks Arkworks Halo2 gnark Constantine
Poseidon ๐Ÿ—๏ธ โœ”๏ธ โœ”๏ธ โŒ โŒ
Pedersen ๐Ÿ—๏ธ โœ”๏ธ โœ”๏ธ โŒ โŒ
Rescue Prime XLIX โŒ โŒ โŒ โŒ โŒ
Elliptic Curves Lambdaworks Arkworks Halo2 gnark Constantine
BLS12-381 โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ
BLS12-377 ๐Ÿ—๏ธ โœ”๏ธ โŒ โœ”๏ธ โœ”๏ธ
BN-254 ๐Ÿ—๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ
Pallas โœ”๏ธ โœ”๏ธ โŒ โŒ โœ”๏ธ
Vesta โœ”๏ธ โœ”๏ธ โŒ โŒ โœ”๏ธ
Bandersnatch ๐Ÿ—๏ธ โœ”๏ธ โŒ โœ”๏ธ โœ”๏ธ
STARKs Lambdaworks Arkworks Halo2 gnark Constantine
STARK Prover โœ”๏ธ โŒ โŒ โŒ โŒ
CAIRO Prover ๐Ÿ—๏ธ โŒ โŒ โŒ โŒ
SNARKs Lambdaworks Arkworks Halo2 gnark Constantine
Groth16 โœ”๏ธ โœ”๏ธ โŒ โœ”๏ธ โŒ
Plonk ๐Ÿ—๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โŒ
Spartan โŒ โœ”๏ธ โŒ โŒ โŒ
Marlin โŒ โœ”๏ธ โŒ โŒ โŒ
GKR โŒ โœ”๏ธ โŒ โœ”๏ธ โŒ
Polynomial Commitment Schemes Lambdaworks Arkworks Halo2 gnark Constantine
FRI ๐Ÿ—๏ธ โŒ โŒ โœ”๏ธ โŒ
IPA ๐Ÿ—๏ธ โœ”๏ธ โœ”๏ธ โŒ โŒ
Hyrax โŒ โœ”๏ธ โŒ โŒ โŒ
KZG10 โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โŒ
Folding Schemes Lambdaworks Arkworks Halo2 gnark Constantine
Nova โŒ โœ”๏ธ โŒ โŒ โŒ
Supernova โŒ โŒ โŒ โŒ โŒ
Protostar โŒ โŒ โŒ โŒ โŒ
Protogalaxy โŒ โœ”๏ธ โŒ โŒ โŒ

Additionally, provers are compatible with the following frontends and VMs:

Backend Frontend Status
Groth16 Arkworks โœ”๏ธ
Groth16 Gnark โŒ
Groth16 Circom ๐Ÿ—๏ธ
Plonk Gnark ๐Ÿ—๏ธ
Plonk Noir โŒ
Stark Winterfell โœ”๏ธ
Stark Miden โœ”๏ธ
Stark Cairo โœ”๏ธ

This can be used in a multi prover setting for extra security, or as a standalone to be used with Rust.

Additional tooling usage

Fuzzers

Fuzzers are divided between the ones that use only the CPU, the ones that use Metal, and the ones that use CUDA.

CPU Fuzzers can be run with the command bash make run-fuzzer FUZZER=fuzzer_name

For example:

make run-fuzzer FUZZER=field_from_hex

The list of fuzzers can be found in fuzz/no_gpu_fuzz

Fuzzers for FTT in Metal and Cuda can be run with make run-metal-fuzzer and make run-cuda-fuzzer

Run a specific fuzzer from the ones contained in fuzz/fuzz_targets/ folder withcargo, for example to run the one for the target field_from_hex:

make run-fuzzer FUZZER=field_from_hex

Documentation building

To serve the documentation locally, first install both mdbook and the Katex preprocessor to render LaTeX, then run

make docs

๐Ÿ“Š Benchmarks

Benchmark results are hosted here.

These are the results of execution of the benchmarks for finite field arithmetic using the STARK field prime (p = 3618502788666131213697322783095070105623107215331596699973092056135872020481).

Differences of 3% are common for some measurements, so small differences are not statistically relevant.

ARM - M1

Operation N Arkworks lambdaworks
mul 10k 112 ฮผs 115 ฮผs
add 1M 8.5 ms 7.0 ms
sub 1M 7.53 ms 7.12 ms
pow 10k 11.2 ms 12.4 ms
invert 10k 30.0 ms 27.2 ms

x86 - AMD Ryzen 7 PRO

Operation N Arkworks (ASM)* lambdaworks
mul 10k 118.9 us 95.7 us
add 1M 6.8 ms 5.4 ms
sub 1M 6.6 ms 5.2 ms
pow 10k 10.6 ms 9.4 ms
invert 10k 34.2 ms 35.74 ms

*assembly feature was enabled manually for that bench, and is not activated by default when running criterion

To run them locally, you will need cargo-criterion and cargo-flamegraph. Install it with:

cargo install cargo-criterion

Run the complete benchmark suite with:

make benchmarks

Run a specific benchmark suite with cargo, for example to run the one for field:

make benchmark BENCH=field

You can check the generated HTML report in target/criterion/reports/index.html

๐Ÿ“š References

The following links, repos and projects have been important in the development of this library and we want to thank and acknowledge them.

lambdaworks's People

Contributors

maurotoscano avatar schouhy avatar unbalancedparentheses avatar diegokingston avatar pablodeymo avatar ajgara avatar xqft avatar entropidelic avatar oppen avatar jrchatruc avatar gabrielbosio avatar mpaulucci avatar megaredhand avatar mdvillagra avatar patstiles avatar ilitteri avatar juan518munoz avatar fmoletta avatar franfiuba avatar iavecilla avatar tcoratger avatar daphneherlambda avatar feltroidprime avatar juan-m-v avatar gianfrancobazzani avatar aminarria avatar dbejarano820 avatar matias-gonz avatar techiepriyansh avatar startup-dreamer 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.