subspace_proof_of_space/
lib.rs1#![no_std]
3#![expect(incomplete_features, reason = "generic_const_exprs")]
4#![warn(rust_2018_idioms, missing_debug_implementations, missing_docs)]
5#![feature(
6 array_windows,
7 const_trait_impl,
8 exact_size_is_empty,
9 generic_const_exprs,
10 get_mut_unchecked,
11 maybe_uninit_fill,
12 maybe_uninit_slice,
13 maybe_uninit_write_slice,
14 portable_simd,
15 step_trait,
16 sync_unsafe_cell,
17 vec_into_raw_parts
18)]
19
20pub mod chia;
21pub mod chiapos;
22pub mod shim;
23
24#[cfg(feature = "alloc")]
25extern crate alloc;
26
27#[cfg(feature = "alloc")]
28use core::fmt;
29use subspace_core_primitives::pos::{PosProof, PosSeed};
30use subspace_core_primitives::solutions::SolutionPotVerifier;
31
32#[derive(Debug, Clone, Copy)]
34pub enum PosTableType {
35 Chia,
37 Shim,
39}
40
41#[cfg(feature = "alloc")]
45pub trait TableGenerator<T: Table>:
46 fmt::Debug + Default + Clone + Send + Sync + Sized + 'static
47{
48 fn generate(&self, seed: &PosSeed) -> T;
52
53 #[cfg(feature = "parallel")]
58 fn generate_parallel(&self, seed: &PosSeed) -> T {
59 self.generate(seed)
60 }
61}
62
63pub trait Table: SolutionPotVerifier + Sized + Send + Sync + 'static {
65 const TABLE_TYPE: PosTableType;
67 #[cfg(feature = "alloc")]
69 type Generator: TableGenerator<Self>;
70
71 #[cfg(feature = "alloc")]
73 fn find_proof(&self, challenge_index: u32) -> Option<PosProof>;
74
75 fn is_proof_valid(seed: &PosSeed, challenge_index: u32, proof: &PosProof) -> bool;
77
78 #[cfg(feature = "alloc")]
80 fn generator() -> Self::Generator {
81 Self::Generator::default()
82 }
83}