sov_rollup_interface/state_machine/crypto/
simple_hasher.rs1use digest::typenum::U32;
2use digest::{Digest, FixedOutput, FixedOutputReset, OutputSizeUser, Reset, Update};
3
4pub struct NoOpHasher;
7
8impl OutputSizeUser for NoOpHasher {
9 type OutputSize = U32;
10}
11
12impl Update for NoOpHasher {
13 fn update(&mut self, _data: &[u8]) {}
14}
15
16impl Reset for NoOpHasher {
17 fn reset(&mut self) {}
18}
19
20impl FixedOutput for NoOpHasher {
21 fn finalize_into(self, out: &mut digest::Output<Self>) {
22 *out = [0u8; 32].into();
23 }
24}
25
26impl FixedOutputReset for NoOpHasher {
27 fn finalize_into_reset(&mut self, out: &mut digest::Output<Self>) {
28 *out = [0u8; 32].into();
29 }
30}
31
32impl Digest for NoOpHasher {
33 fn new() -> Self {
34 Self
35 }
36
37 fn new_with_prefix(_data: impl AsRef<[u8]>) -> Self {
38 Self
39 }
40
41 fn update(&mut self, _data: impl AsRef<[u8]>) {}
42
43 fn chain_update(self, _data: impl AsRef<[u8]>) -> Self {
44 Self
45 }
46
47 fn finalize(self) -> digest::Output<Self> {
48 [0u8; 32].into()
49 }
50
51 fn finalize_into(self, out: &mut digest::Output<Self>) {
52 <Self as FixedOutput>::finalize_into(self, out)
53 }
54
55 fn finalize_reset(&mut self) -> digest::Output<Self>
56 where
57 Self: digest::FixedOutputReset,
58 {
59 [0u8; 32].into()
60 }
61
62 fn finalize_into_reset(&mut self, out: &mut digest::Output<Self>)
63 where
64 Self: digest::FixedOutputReset,
65 {
66 <Self as FixedOutputReset>::finalize_into_reset(self, out)
67 }
68
69 fn reset(&mut self)
70 where
71 Self: digest::Reset,
72 {
73 <Self as Reset>::reset(self)
74 }
75
76 fn output_size() -> usize {
77 32
78 }
79
80 fn digest(_data: impl AsRef<[u8]>) -> digest::Output<Self> {
81 [0u8; 32].into()
82 }
83}