1pub use crate::{BLOCK_LEN, CHUNK_LEN};
4
5#[derive(Clone, Debug)]
6pub struct ChunkState(crate::ChunkState);
7
8impl ChunkState {
9 pub fn new(chunk_counter: u64) -> Self {
12 Self(crate::ChunkState::new(
13 crate::IV,
14 chunk_counter,
15 0,
16 crate::platform::Platform::detect(),
17 ))
18 }
19
20 #[inline]
21 pub fn len(&self) -> usize {
22 self.0.count()
23 }
24
25 #[inline]
26 pub fn update(&mut self, input: &[u8]) -> &mut Self {
27 self.0.update(input);
28 self
29 }
30
31 pub fn finalize(&self, is_root: bool) -> crate::Hash {
32 let output = self.0.output();
33 if is_root {
34 output.root_hash()
35 } else {
36 output.chaining_value().into()
37 }
38 }
39}
40
41pub fn parent_cv(
44 left_child: &crate::Hash,
45 right_child: &crate::Hash,
46 is_root: bool,
47) -> crate::Hash {
48 let output = crate::parent_node_output(
49 left_child.as_bytes(),
50 right_child.as_bytes(),
51 crate::IV,
52 0,
53 crate::platform::Platform::detect(),
54 );
55 if is_root {
56 output.root_hash()
57 } else {
58 output.chaining_value().into()
59 }
60}