cosmwasm_crypto/
identity_digest.rs1use digest::consts::U32;
7use digest::generic_array::GenericArray;
8use digest::{FixedOutput, HashMarker, Output, OutputSizeUser, Reset, Update};
9
10#[derive(Clone, Default)]
12pub struct Identity256 {
13 array: GenericArray<u8, U32>,
14}
15
16impl Update for Identity256 {
17 fn update(&mut self, hash: &[u8]) {
18 assert_eq!(hash.as_ref().len(), 32);
19 self.array = *GenericArray::from_slice(hash);
20 }
21}
22
23impl OutputSizeUser for Identity256 {
24 type OutputSize = U32;
25}
26
27impl FixedOutput for Identity256 {
28 fn finalize_into(self, out: &mut Output<Self>) {
29 *out = self.array;
30 }
31}
32
33impl HashMarker for Identity256 {}
34
35impl Reset for Identity256 {
36 fn reset(&mut self) {
37 *self = Self::default();
38 }
39}