|
1 | | -# Ristretto Bulletproofs |
2 | | - |
3 | | -A pure-Rust implementation of [Bulletproofs][bp_website] using [Ristretto][ristretto]. |
4 | | - |
5 | | -This crate contains both an implementation and a set of notes on how and why |
6 | | -Bulletproofs work. The [external documentation][doc_external] describes how to use this |
7 | | -crate’s API, while the [internal documentation][doc_internal] contains the notes. |
8 | | - |
9 | | -## WARNING |
10 | | - |
11 | | -This code is still research-quality. It is not (yet) suitable for deployment. |
| 1 | +# Bulletproofs |
| 2 | + |
| 3 | +<img |
| 4 | + width="100%" |
| 5 | + src="https://user-images.githubusercontent.com/698/46373713-9cc40280-c643-11e8-9bfe-2b0586e40369.png" |
| 6 | +/> |
| 7 | + |
| 8 | +The fastest [Bulletproofs][bp_website] implementation ever, featuring |
| 9 | +single and aggregated range proofs, strongly-typed multiparty |
| 10 | +computation, and a programmable constraint system API for proving |
| 11 | +arbitrary statements (under development). |
| 12 | + |
| 13 | +This library implements Bulletproofs using [Ristretto][ristretto], |
| 14 | +using the `ristretto255` implementation in |
| 15 | +[`curve25519-dalek`][curve25519_dalek]. When using the [parallel |
| 16 | +formulas][parallel_edwards] in the `curve25519-dalek` AVX2 backend, it |
| 17 | +can verify 64-bit rangeproofs **approximately twice as fast** as the |
| 18 | +original `libsecp256k1`-based Bulletproofs implementation. |
| 19 | + |
| 20 | +This library provides implementations of: |
| 21 | + |
| 22 | +* Single-party proofs of single or multiple ranges, using the |
| 23 | + aggregated rangeproof construction; |
| 24 | + |
| 25 | +* Online multi-party computation for rangeproof aggregation between |
| 26 | + multiple parties, using [session types][session_type_blog] to |
| 27 | + statically enforce correct protocol flow; |
| 28 | + |
| 29 | +* A programmable constraint system API for expressing rank-1 |
| 30 | + constraint systems, and proving and verifying proofs of arbitrary |
| 31 | + statements (under development in the `circuit` branch); |
| 32 | + |
| 33 | +* Online multi-party computation for aggregated circuit proofs |
| 34 | + (planned future work). |
| 35 | + |
| 36 | +These proofs are implemented using [Merlin transcripts][doc_merlin], |
| 37 | +allowing them to be arbitrarily composed with other proofs without |
| 38 | +implementation changes. |
12 | 39 |
|
13 | 40 | ## Documentation |
| 41 | + |
| 42 | +The user-facing documentation for this functionality can be [found |
| 43 | +here][doc_external]. In addition, the library *also* contains |
| 44 | +extensive notes on how Bulletproofs work. These notes can be found in |
| 45 | +the library's [internal documentation][doc_internal]: |
| 46 | + |
| 47 | +* how [Bulletproofs work][bp_notes]; |
| 48 | +* how [the range proof protocol works][rp_notes]; |
| 49 | +* how [the inner product proof protocol works][ipp_notes]; |
| 50 | +* how [the aggregation protocol works][agg_notes]; |
| 51 | +* how the Bulletproof circuit proofs work (under development); |
| 52 | +* how the constraint system reduction works (under development); |
| 53 | +* how the aggregated circuit proofs work (future work). |
| 54 | + |
| 55 | +## Comparative Performance |
| 56 | + |
| 57 | +The following table gives comparative timings for proving and |
| 58 | +verification of a 64-bit rangeproof on an i7-7800X with Turbo Boost |
| 59 | +disabled. Times are in microseconds (lower is better), with the |
| 60 | +relative speed compared to the fastest implementation. |
| 61 | + |
| 62 | +| Implementation | Group | Proving (μs) | rel | Verification (μs) | rel | |
| 63 | +|----------------|------------------|-------------:|----------:|------------------:|----------:| |
| 64 | +| ours (avx2) | ristretto255 | 7300 | **1.00x** | 1040 | **1.00x** | |
| 65 | +| ours (u64) | ristretto255 | 11300 | **1.54x** | 1490 | **1.43x** | |
| 66 | +| libsecp+endo | secp256k1 | 14300 | **1.96x** | 1900 | **1.83x** | |
| 67 | +| libsecp-endo | secp256k1 | 16800 | **2.30x** | 2080 | **2.00x** | |
| 68 | +| Monero | ed25519 (unsafe) | 53300 | **7.30x** | 4810 | **4.63x** | |
| 69 | + |
| 70 | +This crate also contains other benchmarks; see the *Benchmarks* |
| 71 | +section below for details. |
14 | 72 |
|
15 | | -* [Public API documentation][doc_external] |
16 | | -* [Internal documentation][doc_internal] |
17 | | - * [Notes on how Bulletproofs work][bp_notes] (located in the internal `notes` module) |
18 | | - * [Range proof protocol description][rp_notes] |
19 | | - * [Inner product protocol description][ipp_notes] |
20 | | - |
21 | | - |
22 | | -Unfortunately, `cargo doc` does not yet have support for custom HTML injection |
23 | | -and for documenting private members, so the documentation is built using: |
24 | | - |
25 | | -```text |
26 | | -make doc # Builds external documentation |
27 | | -make doc-internal # Builds internal documentation |
28 | | -``` |
| 73 | +## WARNING |
29 | 74 |
|
30 | | -Note: `cargo doc --open` rebuilds the docs without the custom |
31 | | -invocation, so it may be necessary to rerun `make`. |
| 75 | +This code is still research-quality. It is not (yet) suitable for |
| 76 | +deployment. The development roadmap can be found in the |
| 77 | +[Milestones][gh_milestones] section of the [Github repo][gh_repo]. |
32 | 78 |
|
33 | 79 | ## Tests |
34 | 80 |
|
35 | 81 | Run tests with `cargo test`. |
36 | 82 |
|
37 | 83 | ## Benchmarks |
38 | 84 |
|
39 | | -This crate uses [criterion.rs][criterion] for benchmarks. Run benchmarks with |
40 | | -`cargo bench`. |
| 85 | +This crate uses [criterion.rs][criterion] for benchmarks. Run |
| 86 | +benchmarks with `cargo bench`. |
41 | 87 |
|
42 | 88 | ## Features |
43 | 89 |
|
44 | | -The `yolocrypto` feature enables the `yolocrypto` feature in |
45 | | -`curve25519-dalek`, which enables the experimental AVX2 backend. To use it for |
46 | | -Bulletproofs, the `target_cpu` must support AVX2: |
| 90 | +The `avx2_backend` feature enables `curve25519-dalek`'s AVX2 backend, |
| 91 | +which implements curve arithmetic using [parallel |
| 92 | +formulas][parallel_edwards]. To use it for Bulletproofs, the |
| 93 | +`target_cpu` must support AVX2: |
47 | 94 |
|
48 | 95 | ```text |
49 | | -RUSTFLAGS="-C target_cpu=skylake" cargo bench --features "yolocrypto" |
| 96 | +RUSTFLAGS="-C target_cpu=skylake" cargo bench --features "avx2_backend" |
50 | 97 | ``` |
51 | 98 |
|
52 | 99 | Skylake-X CPUs have double the AVX2 registers. To use them, try |
53 | 100 |
|
54 | 101 | ```text |
55 | | -RUSTFLAGS="-C target_cpu=skylake-avx512" cargo bench --features "yolocrypto" |
| 102 | +RUSTFLAGS="-C target_cpu=skylake-avx512" cargo bench --features "avx2_backend" |
56 | 103 | ``` |
57 | 104 |
|
58 | 105 | This prevents spills in the AVX2 parallel field multiplication code, but causes |
59 | 106 | worse code generation elsewhere ¯\\\_(ツ)\_/¯ |
60 | 107 |
|
61 | 108 | ## About |
62 | 109 |
|
63 | | -This is a research project being built for Chain, Inc, by Henry de Valence, |
64 | | -Cathie Yun, and Oleg Andreev. |
| 110 | +This is a research project sponsored by [Interstellar][interstellar], |
| 111 | +developed by Henry de Valence, Cathie Yun, and Oleg Andreev. |
65 | 112 |
|
66 | 113 | [bp_website]: https://crypto.stanford.edu/bulletproofs/ |
67 | | -[ristretto]: https://doc.dalek.rs/curve25519_dalek/ristretto/index.html |
68 | | -[doc_external]: https://doc.dalek.rs/ristretto_bulletproofs/index.html |
69 | | -[doc_internal]: https://doc-internal.dalek.rs/ristretto_bulletproofs/index.html |
70 | | -[bp_notes]: https://doc-internal.dalek.rs/ristretto_bulletproofs/notes/index.html |
71 | | -[rp_notes]: https://doc-internal.dalek.rs/ristretto_bulletproofs/range_proof/index.html |
72 | | -[ipp_notes]: https://doc-internal.dalek.rs/ristretto_bulletproofs/inner_product_proof/index.html |
| 114 | +[ristretto]: https://ristretto.group |
| 115 | +[doc_merlin]: https://doc.dalek.rs/merlin/index.html |
| 116 | +[doc_external]: https://doc.dalek.rs/bulletproofs/index.html |
| 117 | +[doc_internal]: https://doc-internal.dalek.rs/bulletproofs/index.html |
| 118 | +[bp_notes]: https://doc-internal.dalek.rs/bulletproofs/notes/index.html |
| 119 | +[rp_notes]: https://doc-internal.dalek.rs/bulletproofs/range_proof/index.html |
| 120 | +[ipp_notes]: https://doc-internal.dalek.rs/bulletproofs/inner_product_proof/index.html |
| 121 | +[agg_notes]: https://doc-internal.dalek.rs/bulletproofs/notes/index.html#aggregated-range-proof |
73 | 122 | [criterion]: https://github.com/japaric/criterion.rs |
| 123 | +[session_type_blog]: https://blog.chain.com/bulletproof-multi-party-computation-in-rust-with-session-types-b3da6e928d5d |
| 124 | +[curve25519_dalek]: https://doc.dalek.rs/curve25519_dalek/index.html |
| 125 | +[parallel_edwards]: https://medium.com/@hdevalence/accelerating-edwards-curve-arithmetic-with-parallel-formulas-ac12cf5015be |
| 126 | +[gh_repo]: https://github.com/dalek-cryptography/bulletproofs/ |
| 127 | +[gh_milestones]: https://github.com/dalek-cryptography/bulletproofs/milestones |
| 128 | +[interstellar]: https://interstellar.com/ |
0 commit comments