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(const_trait_impl, generic_const_exprs, step_trait)]
6#![cfg_attr(feature = "alloc", feature(get_mut_unchecked, maybe_uninit_fill))]
7#![cfg_attr(any(feature = "alloc", test), feature(portable_simd))]
8#![cfg_attr(feature = "parallel", feature(exact_size_is_empty, sync_unsafe_cell))]
9
10pub mod chia;
11pub mod chiapos;
12pub mod shim;
13
14#[cfg(feature = "alloc")]
15extern crate alloc;
16
17#[cfg(feature = "alloc")]
18use core::fmt;
19use subspace_core_primitives::pos::{PosProof, PosSeed};
20use subspace_core_primitives::solutions::SolutionPotVerifier;
21
22#[derive(Debug, Clone, Copy)]
24pub enum PosTableType {
25 Chia,
27 Shim,
29}
30
31#[cfg(feature = "alloc")]
35pub trait TableGenerator<T: Table>:
36 fmt::Debug + Default + Clone + Send + Sync + Sized + 'static
37{
38 fn generate(&self, seed: &PosSeed) -> T;
42
43 #[cfg(feature = "parallel")]
48 fn generate_parallel(&self, seed: &PosSeed) -> T {
49 self.generate(seed)
50 }
51}
52
53pub trait Table: SolutionPotVerifier + Sized + Send + Sync + 'static {
55 const TABLE_TYPE: PosTableType;
57 #[cfg(feature = "alloc")]
59 type Generator: TableGenerator<Self>;
60
61 #[cfg(feature = "alloc")]
63 fn find_proof(&self, challenge_index: u32) -> Option<PosProof>;
64
65 fn is_proof_valid(seed: &PosSeed, challenge_index: u32, proof: &PosProof) -> bool;
67
68 #[cfg(feature = "alloc")]
70 fn generator() -> Self::Generator {
71 Self::Generator::default()
72 }
73}