equihash/
lib.rs

1//! Equihash is a Proof-of-Work algorithm, based on a generalization of the Birthday
2//! problem which finds colliding hash values. It was designed to be memory-hard; more
3//! specifically, the bottle-neck for parallel implementations of Equihash solvers would
4//! be memory bandwidth.
5//!
6//! This crate implements Equihash as specified for the Zcash consensus rules. It can
7//! verify solutions for any valid `(n, k)` parameters, as long as the row indices are no
8//! larger than 32 bits (that is, `ceiling(((n / (k + 1)) + 1) / 8) <= 4`).
9//!
10#![cfg_attr(feature = "std", doc = "## Feature flags")]
11#![cfg_attr(feature = "std", doc = document_features::document_features!())]
12//!
13//! References
14//! ==========
15//! - [Section 7.6.1: Equihash.] Zcash Protocol Specification, version 2020.1.10 or later.
16//! - Alex Biryukov and Dmitry Khovratovich.
17//!   [*Equihash: Asymmetric Proof-of-Work Based on the Generalized Birthday Problem.*][BK16]
18//!   NDSS ’16.
19//!
20//! [Section 7.6.1: Equihash.]: https://zips.z.cash/protocol/protocol.pdf#equihash
21//! [BK16]: https://www.internetsociety.org/sites/default/files/blogs-media/equihash-asymmetric-proof-of-work-based-generalized-birthday-problem.pdf
22
23// Catch documentation errors caused by code changes.
24#![deny(rustdoc::broken_intra_doc_links)]
25#![no_std]
26#![cfg_attr(docsrs, feature(doc_cfg))]
27#![cfg_attr(docsrs, feature(doc_auto_cfg))]
28
29#[cfg(feature = "std")]
30extern crate std;
31
32#[macro_use]
33extern crate alloc;
34
35mod minimal;
36mod params;
37mod verify;
38
39#[cfg(test)]
40mod test_vectors;
41
42pub use verify::{is_valid_solution, Error};
43
44#[cfg(feature = "solver")]
45mod blake2b;
46#[cfg(feature = "solver")]
47pub mod tromp;