chia_protocol/
partial_proof.rs

1use crate::Bytes32;
2use chia_pos2::serialize_quality;
3use chia_sha2::Sha256;
4use chia_streamable_macro::streamable;
5
6#[cfg(feature = "py-bindings")]
7use pyo3::pymethods;
8
9#[streamable]
10pub struct PartialProof {
11    #[cfg_attr(feature = "serde", serde(with = "serde_arrays"))]
12    fragments: [u64; 16],
13}
14
15impl PartialProof {
16    pub fn get_string(&self, strength: u8) -> Bytes32 {
17        let mut sha256 = Sha256::new();
18        sha256.update(serialize_quality(&self.fragments, strength));
19        sha256.finalize().into()
20    }
21}
22
23#[cfg(feature = "py-bindings")]
24#[pymethods]
25impl PartialProof {
26    #[pyo3(name = "get_string")]
27    fn py_get_string(&self, strength: u8) -> Bytes32 {
28        self.get_string(strength)
29    }
30}