mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-16 12:28:24 +00:00
* Move tests -> testing * Directory restructure * Update Cargo.toml during restructure * Update Makefile during restructure * Fix arbitrary path
25 lines
601 B
Rust
25 lines
601 B
Rust
use crate::derived_key::HASH_SIZE;
|
|
use zeroize::Zeroize;
|
|
|
|
/// Provides a wrapper around a `[u8; HASH_SIZE]` that implements `Zeroize` on `Drop`.
|
|
#[derive(Zeroize)]
|
|
#[zeroize(drop)]
|
|
pub struct SecretHash([u8; HASH_SIZE]);
|
|
|
|
impl SecretHash {
|
|
/// Instantiates `Self` with all zeros.
|
|
pub fn zero() -> Self {
|
|
Self([0; HASH_SIZE])
|
|
}
|
|
|
|
/// Returns a reference to the underlying bytes.
|
|
pub fn as_bytes(&self) -> &[u8] {
|
|
&self.0
|
|
}
|
|
|
|
/// Returns a mutable reference to the underlying bytes.
|
|
pub fn as_mut_bytes(&mut self) -> &mut [u8] {
|
|
&mut self.0
|
|
}
|
|
}
|