1#![cfg_attr(not(feature = "std"), 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_convert,
8 const_trait_impl,
9 exact_size_is_empty,
10 generic_const_exprs,
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
24use ab_core_primitives::pos::{PosProof, PosSeed};
25use ab_core_primitives::solutions::SolutionPotVerifier;
26#[cfg(feature = "alloc")]
27use core::fmt;
28
29#[derive(Debug, Clone, Copy)]
31pub enum PosTableType {
32 Chia,
34 Shim,
36}
37
38#[cfg(feature = "alloc")]
40pub trait TableGenerator<T: Table>: fmt::Debug + Default + Clone + Send + Sized + 'static {
41 fn generate(&mut self, seed: &PosSeed) -> T;
45
46 #[cfg(any(feature = "parallel", test))]
51 fn generate_parallel(&mut self, seed: &PosSeed) -> T {
52 self.generate(seed)
53 }
54}
55
56pub trait Table: SolutionPotVerifier + Sized + Send + Sync + 'static {
58 const TABLE_TYPE: PosTableType;
60 #[cfg(feature = "alloc")]
62 type Generator: TableGenerator<Self>;
63
64 #[cfg(feature = "alloc")]
68 fn generate(seed: &PosSeed) -> Self;
69
70 #[cfg(all(feature = "alloc", any(feature = "parallel", test)))]
75 fn generate_parallel(seed: &PosSeed) -> Self {
76 Self::generate(seed)
77 }
78
79 #[cfg(feature = "alloc")]
81 fn find_proof(&self, challenge_index: u32) -> Option<PosProof>;
82
83 fn is_proof_valid(seed: &PosSeed, challenge_index: u32, proof: &PosProof) -> bool;
85
86 #[cfg(feature = "alloc")]
88 fn generator() -> Self::Generator {
89 Self::Generator::default()
90 }
91}