You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
6.5 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
4 years ago
5 years ago
5 years ago
  1. <h1 align="center">ZEXE (Zero knowledge EXEcution)</h1>
  2. <p align="center">
  3. <a href="https://travis-ci.org/scipr-lab/zexe"><img src="https://travis-ci.org/scipr-lab/zexe.svg?branch=master"></a>
  4. <a href="https://github.com/scipr-lab/zexe/blob/master/AUTHORS"><img src="https://img.shields.io/badge/authors-SCIPR%20Lab-orange.svg"></a>
  5. <a href="https://github.com/scipr-lab/zexe/blob/master/LICENSE-APACHE"><img src="https://img.shields.io/badge/license-APACHE-blue.svg"></a>
  6. <a href="https://github.com/scipr-lab/zexe/blob/master/LICENSE-MIT"><img src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
  7. <a href="https://deps.rs/repo/github/scipr-lab/zexe"><img src="https://deps.rs/repo/github/scipr-lab/zexe/status.svg"></a>
  8. </p>
  9. ___ZEXE___ (pronounced */zeksē/*) is a Rust library for decentralized private computation.
  10. This library was initially developed as part of the paper *"[ZEXE: Enabling Decentralized Private Computation][zexe]"*, and it is released under the MIT License and the Apache v2 License (see [License](#license)).
  11. **WARNING:** This is an academic proof-of-concept prototype, and in particular has not received careful code review. This implementation is NOT ready for production use.
  12. ## Overview
  13. This library implements a ledger-based system that enables users to execute offline computations and subsequently produce publicly-verifiable transactions that attest to the correctness of these offline executions. The transactions contain *zero-knowledge succinct arguments* (zkSNARKs) attesting to the correctness of the offline computations, and provide strong notions of privacy and succinctness.
  14. - **Privacy** - transactions reveal no information about the offline computation.
  15. - **Succinctness** - transactions can be validated in time that is independent of the offline computation.
  16. - **Application isolation** - malicious applications cannot affect the execution of honest applications.
  17. - **Application interaction** - applications can safely communicate with each other.
  18. Informally, the library provides the ability to create transactions that run arbitrary (Turing-complete) scripts on hidden data stored on the ledger. In more detail, the library implements a cryptographic primitive known as *decentralized private computation* (DPC) schemes, which are described in detail in the [ZEXE paper][zexe].
  19. ## Directory structure
  20. This repository contains several Rust crates that implement the different building blocks of ZEXE. The high-level structure of the repository is as follows.
  21. * [`algebra`](algebra): Rust crate that provides finite fields and elliptic curves
  22. * [`crypto-primitives`](crypto-primitives): Rust crate that implements some useful cryptographic primitives (and constraints for them)
  23. * [`dpc`](dpc): Rust crate that implements DPC schemes (the main cryptographic primitive in this repository)
  24. * [`ff-fft`](ff-fft): Rust crate that provides efficient finite field polynomial arithmetic based on finite field FFTs
  25. * [`r1cs-core`](r1cs-core): Rust crate that defines core interfaces for a Rank-1 Constraint System (R1CS)
  26. * [`r1cs-std`](r1cs-std): Rust crate that provides various gadgets used to construct R1CS
  27. * [`gm17`](gm17): Rust crate that implements the zkSNARK of [Groth and Maller][GM17]
  28. * [`groth16`](groth16): Rust crate that implements the zkSNARK of [Groth][Groth16]
  29. In addition, there is a [`bench-utils`](bench-utils) crate which contains infrastructure for benchmarking. This crate includes macros for timing code segments and is used for profiling the building blocks of ZEXE.
  30. [GM17]: https://ia.cr/2017/540
  31. [Groth16]: https://ia.cr/2016/260
  32. ## Build guide
  33. The library compiles on the `stable` toolchain of the Rust compiler. To install the latest version of Rust, first install `rustup` by following the instructions [here](https://rustup.rs/), or via your platform's package manager. Once `rustup` is installed, install the Rust toolchain by invoking:
  34. ```bash
  35. rustup install stable
  36. ```
  37. After that, use `cargo`, the standard Rust build tool, to build the library:
  38. ```bash
  39. git clone https://github.com/scipr-lab/zexe.git
  40. cd zexe/dpc
  41. cargo build --release
  42. ```
  43. This library comes with unit tests for each of the provided crates. Run the tests with:
  44. ```bash
  45. cargo test
  46. ```
  47. This library comes with benchmarks for the following crates:
  48. - [`algebra`](algebra)
  49. - [`dpc`](dpc)
  50. These benchmarks require the nightly Rust toolchain; to install this, run `rustup install nightly`. Then, to run benchmarks, run the following command:
  51. ```bash
  52. cargo +nightly bench
  53. ```
  54. Compiling with `adcxq`, `adoxq` and `mulxq` instructions can lead to a 30-70% speedup. These are available on most `x86_64` platforms (Broadwell onwards for Intel and Ryzen onwards for AMD). Run the following command:
  55. ```bash
  56. RUSTFLAGS="--emit=asm -C target-feature=+bmi2,+adx" cargo +nightly test/build/bench --features asm
  57. ```
  58. To bench `algebra-benches` with greater accuracy, especially for functions with execution times on the order of nanoseconds, use the `n_fold` feature. To run with multiple features, make sure to double quote the features.
  59. ```bash
  60. cargo +nightly bench --features "n_fold bls12_381"
  61. ```
  62. ## License
  63. ZEXE is licensed under either of the following licenses, at your discretion.
  64. * Apache License Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
  65. * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
  66. Unless you explicitly state otherwise, any contribution submitted for inclusion in ZEXE by you shall be dual licensed as above (as defined in the Apache v2 License), without any additional terms or conditions.
  67. [zexe]: https://ia.cr/2018/962
  68. ## Reference paper
  69. [_ZEXE: Enabling Decentralized Private Computation_][zexe]
  70. [Sean Bowe](https://www.github.com/ebfull), Alessandro Chiesa, Matthew Green, Ian Miers, [Pratyush Mishra](https://www.github.com/pratyush), [Howard Wu](https://www.github.com/howardwu)
  71. *IEEE S&P 2020* (*IACR ePrint Report 2018/962*)
  72. ## Acknowledgements
  73. This work was supported by:
  74. a Google Faculty Award;
  75. the National Science Foundation;
  76. the UC Berkeley Center for Long-Term Cybersecurity;
  77. and donations from the Ethereum Foundation, the Interchain Foundation, and Qtum.
  78. Some parts of the finite field arithmetic, elliptic curve arithmetic, FFTs, and multi-threading infrastructure in the `algebra` crate have been adapted from code in the [`ff`](https://github.com/zkcrypto/ff), [`pairing`](https://github.com/zkcrypto/pairing), and [`bellman`](https://github.com/zkcrypto/bellman) crates, developed by [Sean Bowe](https://www.github.com/ebfull) and others from Zcash.