storage_proofs_core/
lib.rs

1#![deny(clippy::all, clippy::perf, clippy::correctness, rust_2018_idioms)]
2#![allow(clippy::many_single_char_names)]
3#![allow(clippy::unreadable_literal)]
4#![allow(clippy::type_repetition_in_bounds)]
5#![allow(clippy::upper_case_acronyms)]
6#![allow(clippy::redundant_slicing)]
7#![allow(clippy::unnecessary_wraps)]
8#![warn(clippy::unwrap_used)]
9#![warn(clippy::ptr_arg)]
10#![warn(clippy::unnecessary_lazy_evaluations)]
11
12use std::convert::TryInto;
13
14pub mod api_version;
15pub mod cache_key;
16pub mod compound_proof;
17pub mod crypto;
18pub mod data;
19pub mod drgraph;
20pub mod error;
21pub mod gadgets;
22pub mod measurements;
23pub mod merkle;
24pub mod multi_proof;
25pub mod parameter_cache;
26pub mod partitions;
27pub mod pieces;
28pub mod por;
29pub mod proof;
30pub mod sector;
31pub mod settings;
32pub mod test_helper;
33pub mod util;
34
35pub use data::Data;
36
37pub const TEST_SEED: [u8; 16] = [
38    0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, 0xe5,
39];
40
41pub const MAX_LEGACY_POREP_REGISTERED_PROOF_ID: u64 = 4;
42
43pub type PoRepID = [u8; 32];
44
45pub fn is_legacy_porep_id(porep_id: PoRepID) -> bool {
46    // NOTE: Because we take only the first 8 bytes, we are actually examining the registered proof type id,
47    // not the porep_id. The latter requires the full 32 bytes and includes the nonce.
48    // We are, to some extent depending explictly on the strucuture of the `porep_id`.
49    // Of course, it happens to be the case that only the 'legacy' ids in question can ever satisfy
50    // this predicate, so the distinction is somewhat moot. However, for the sake of clarity in any future
51    // use of `porep_id`, we should pay close attention to this.
52    let id = u64::from_le_bytes(
53        porep_id[..8]
54            .try_into()
55            .expect("8 bytes is always a valid u64"),
56    );
57    id <= MAX_LEGACY_POREP_REGISTERED_PROOF_ID
58}