ab_proof_of_space/
chia.rs1#[cfg(all(feature = "alloc", test, not(miri)))]
4mod tests;
5
6#[cfg(feature = "alloc")]
7use crate::PosProofs;
8#[cfg(feature = "alloc")]
9use crate::TableGenerator;
10use crate::chiapos::Tables;
11use crate::{PosTableType, Table};
12use ab_core_primitives::pos::{PosProof, PosSeed};
13use ab_core_primitives::sectors::SBucket;
14#[cfg(feature = "alloc")]
15use alloc::boxed::Box;
16
17const K: u8 = PosProof::K;
18
19#[derive(Debug, Default, Clone)]
23#[cfg(feature = "alloc")]
24pub struct ChiaTableGenerator;
25
26#[cfg(feature = "alloc")]
27impl TableGenerator<ChiaTable> for ChiaTableGenerator {
28 fn create_proofs(&self, seed: &PosSeed) -> Box<PosProofs> {
29 Tables::<K>::create_proofs((*seed).into()).into()
30 }
31
32 #[cfg(feature = "parallel")]
33 fn create_proofs_parallel(&self, seed: &PosSeed) -> Box<PosProofs> {
34 Tables::<K>::create_proofs_parallel((*seed).into()).into()
35 }
36}
37
38#[derive(Debug)]
42pub struct ChiaTable;
43
44impl ab_core_primitives::solutions::SolutionPotVerifier for ChiaTable {
45 #[cfg_attr(feature = "no-panic", no_panic::no_panic)]
46 fn is_proof_valid(seed: &PosSeed, s_bucket: SBucket, proof: &PosProof) -> bool {
47 Tables::<K>::verify_only_raw(seed, u32::from(s_bucket), proof)
48 }
49}
50
51impl Table for ChiaTable {
52 const TABLE_TYPE: PosTableType = PosTableType::Chia;
53 #[cfg(feature = "alloc")]
54 type Generator = ChiaTableGenerator;
55
56 #[cfg_attr(feature = "no-panic", no_panic::no_panic)]
57 fn is_proof_valid(seed: &PosSeed, s_bucket: SBucket, proof: &PosProof) -> bool {
58 <Self as ab_core_primitives::solutions::SolutionPotVerifier>::is_proof_valid(
59 seed, s_bucket, proof,
60 )
61 }
62}