chore: TSMT benchmark

This commit is contained in:
Andrey Khmuro
2023-08-14 12:34:14 +02:00
parent 7780a50dad
commit 2214ff2425
4 changed files with 194 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ use crate::utils::{
DeserializationError, HexParseError, Serializable,
};
use core::{cmp::Ordering, fmt::Display, ops::Deref};
use winter_utils::Randomizable;
/// The number of bytes needed to encoded a digest
pub const DIGEST_BYTES: usize = 32;
@@ -95,6 +96,19 @@ impl Display for RpoDigest {
}
}
impl Randomizable for RpoDigest {
const VALUE_SIZE: usize = DIGEST_BYTES;
fn from_random_bytes(bytes: &[u8]) -> Option<Self> {
let bytes_array: Option<[u8; 32]> = bytes.try_into().ok();
if let Some(bytes_array) = bytes_array {
Self::try_from(bytes_array).ok()
} else {
None
}
}
}
// CONVERSIONS: FROM RPO DIGEST
// ================================================================================================