PLONK
This is a pure Rust implementation of the PLONK proving system over BLS12-381
This library contains a modularised implementation of KZG10 as the default polynomial commitment scheme.
Usage
use dusk-*;
// Implement a circuit that checks:
// 1) a + b = c where C is a PI
// 2) a <= 2^6
// 3) b <= 2^5
// 4) a * b = d where D is a PI
// 5) JubJub::GENERATOR * e(JubJubScalar) = f where F is a Public Input
// Now let's use the Circuit we've just implemented!
let pp = setup?;
// Initialize the circuit
let mut circuit = default;
// Compile the circuit
let = circuit.compile?;
// Prover POV
let proof = ?;
// Verifier POV
let public_inputs: = vec!;
verify_proof
Features
This crate includes a variety of features which will briefly be explained below:
alloc
: Enables the usage of an allocator and with it the capability of performingProof
constructions and verifications. Without this feature it IS NOT possible to prove or verify anything. Its absence only makesdusk-plonk
export certain fixed-size data structures such asProof
which can be useful in no_std envoirments where we don't have allocators either.std
: Enablesstd
usage as well asrayon
parallelisation in some proving and verifying ops. It also uses thestd
versions of the elliptic curve deps, which utilises theparallel
feature fromdusk-bls12-381
. By default, this is the feature that comes enabled with the crate.nightly
: This feature is used to compile the extended docs and has KateX rendering enabled. See theDocumentation
section below.trace
: Enables the Circuit debugger tooling. This is essentially the capability of using theStandardComposer::check_circuit_satisfied
function. The function will output information about each circuit gate until one of the gates does not satisfy the equation, or there are no more gates. If there is an unsatisfied gate equation, the function will panic and return the gate number.trace-print
: Goes a step further thantrace
and prints eachgate
component data, giving a clear overview of all the values which make up the circuit that we're constructing. The recommended method is to derive the std output, and the std error, and then place them in text file which can be used to efficiently analyse the gates.canon
: Enablescanonical
serialisation for particular data structures, which is very useful in integrating this library within the rest of the Dusk stack - especially for storage purposes.
Documentation
There are two main types of documentation in this repository:
-
Crate documentation. This provides info about all of the functions that the library provides, as well as the documentation regarding the data structures that it exports. To check this, please feel free to go to the documentation page or run
make doc
ormake doc-internal
. -
Notes. This is a specific subset of documentation which explains the key mathematical concepts of PLONK and how they work with mathematical demonstrations. To check it, run
make doc
and open the resulting docs, which will be located under/target
with your browser.
Performance
Benchmarks taken on Intel(R) Xeon(R) CPU E5-1620 v4 @ 3.50GHz
.
All results are presented on a min/avg/max time based on the number of constraints performed in a circuit. None of the tests used public inputs and its number may affect the verification time.
Proving performance
2^5 = 32 constraints time: [31.788 ms 31.825 ms 31.862 ms]
2^6 = 64 constraints time: [41.388 ms 41.429 ms 41.471 ms]
2^7 = 128 constraints time: [63.496 ms 63.539 ms 63.573 ms]
2^8 = 256 constraints time: [100.32 ms 100.45 ms 100.68 ms]
2^9 = 512 constraints time: [140.36 ms 140.58 ms 140.78 ms]
2^10 = 1024 constraints time: [256.18 ms 256.48 ms 256.83 ms]
2^11 = 2048 constraints time: [478.55 ms 480.41 ms 482.70 ms]
2^12 = 4096 constraints time: [772.29 ms 776.97 ms 781.71 ms]
2^13 = 8192 constraints time: [1.3406 s 1.3448 s 1.3494 s]
2^14 = 16384 constraints time: [2.6250 s 2.6316 s 2.6379 s]
2^15 = 32768 constraints time: [5.1982 s 5.2228 s 5.2460 s]
2^16 = 65536 constraints time: [9.2356 s 9.3039 s 9.3636 s]
2^17 = 131072 constraints time: [17.836 s 17.883 s 17.936 s]
Verification performance
2^5 = 32 constraints time: [15.287 ms 15.700 ms 16.066 ms]
2^6 = 64 constraints time: [15.172 ms 15.438 ms 15.657 ms]
2^7 = 128 constraints time: [15.335 ms 15.666 ms 15.996 ms]
2^8 = 256 constraints time: [14.988 ms 15.116 ms 15.383 ms]
2^9 = 512 constraints time: [15.047 ms 15.181 ms 15.471 ms]
2^10 = 1024 constraints time: [15.630 ms 15.888 ms 16.303 ms]
2^11 = 2048 constraints time: [15.524 ms 15.719 ms 15.913 ms]
2^12 = 4096 constraints time: [15.178 ms 15.445 ms 15.593 ms]
2^13 = 8192 constraints time: [15.437 ms 15.874 ms 16.553 ms]
2^14 = 16384 constraints time: [16.059 ms 16.386 ms 16.608 ms]
2^15 = 32768 constraints time: [15.969 ms 16.357 ms 16.660 ms]
2^16 = 65536 constraints time: [16.233 ms 16.462 ms 16.639 ms]
2^17 = 131072 constraints time: [18.213 ms 18.680 ms 18.886 ms]
Acknowledgements
- Reference implementation AztecProtocol/Barretenberg
- FFT Module and KZG10 Module were taken and modified from zexe/zcash and scipr-lab, respectively.
Licensing
This code is licensed under Mozilla Public License Version 2.0 (MPL-2.0). Please see LICENSE for further info.
About
Implementation designed by the dusk team.
Contributing
- If you want to contribute to this repository/project please, check CONTRIBUTING.md
- If you want to report a bug or request a new feature addition, please open an issue on this repository.