subspace_proof_of_space/
chiapos.rs1mod constants;
4mod table;
5mod tables;
6
7#[cfg(feature = "alloc")]
8pub use crate::chiapos::table::TablesCache;
9use crate::chiapos::tables::TablesGeneric;
10
11type Seed = [u8; 32];
12#[cfg(any(feature = "full-chiapos", test))]
13type Challenge = [u8; 32];
14#[cfg(any(feature = "full-chiapos", test))]
15type Quality = [u8; 32];
16
17#[derive(Debug)]
19pub struct Tables<const K: u8>(TablesGeneric<K>);
20
21macro_rules! impl_any {
22 ($($k: expr$(,)? )*) => {
23 $(
24impl Tables<$k> {
25 #[cfg(feature = "alloc")]
28 pub fn create(seed: Seed, cache: &TablesCache) -> Self {
29 Self(TablesGeneric::<$k>::create(
30 seed, cache,
31 ))
32 }
33
34 #[cfg(feature = "parallel")]
37 pub fn create_parallel(seed: Seed, cache: &TablesCache) -> Self {
38 Self(TablesGeneric::<$k>::create_parallel(
39 seed, cache,
40 ))
41 }
42
43 #[cfg(all(feature = "alloc", any(feature = "full-chiapos", test)))]
45 pub fn find_quality<'a>(
46 &'a self,
47 challenge: &'a Challenge,
48 ) -> impl Iterator<Item = Quality> + 'a {
49 self.0.find_quality(challenge)
50 }
51
52 #[cfg(feature = "alloc")]
54 pub fn find_proof<'a>(
55 &'a self,
56 first_challenge_bytes: [u8; 4],
57 ) -> impl Iterator<Item = [u8; 64 * $k / 8]> + 'a {
58 self.0.find_proof(first_challenge_bytes)
59 }
60
61 pub fn verify_only(
63 seed: &Seed,
64 first_challenge_bytes: [u8; 4],
65 proof_of_space: &[u8; 64 * $k as usize / 8],
66 ) -> bool {
67 TablesGeneric::<$k>::verify_only(seed, first_challenge_bytes, proof_of_space)
68 }
69
70 #[cfg(any(feature = "full-chiapos", test))]
74 pub fn verify(
75 seed: &Seed,
76 challenge: &Challenge,
77 proof_of_space: &[u8; 64 * $k as usize / 8],
78 ) -> Option<Quality> {
79 TablesGeneric::<$k>::verify(seed, challenge, proof_of_space)
80 }
81}
82 )*
83 }
84}
85
86#[cfg(feature = "full-chiapos")]
88impl_any!(15, 16, 18, 19, 21, 22, 23, 24, 25);
89#[cfg(any(feature = "full-chiapos", test))]
90impl_any!(17);
91impl_any!(20);