mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-19 22:08:30 +00:00
Update milagro_bls to new release (#1183)
* Update milagro_bls to new release Signed-off-by: Kirk Baird <baird.k@outlook.com> * Tidy up fake cryptos Signed-off-by: Kirk Baird <baird.k@outlook.com> * move SecretHash to bls and put plaintext back Signed-off-by: Kirk Baird <baird.k@outlook.com>
This commit is contained in:
committed by
Michael Sproul
parent
ce10db15da
commit
197adeff0b
40
crypto/eth2_key_derivation/src/plain_text.rs
Normal file
40
crypto/eth2_key_derivation/src/plain_text.rs
Normal file
@@ -0,0 +1,40 @@
|
||||
use zeroize::Zeroize;
|
||||
|
||||
/// Provides wrapper around `Vec<u8>` that implements `Zeroize`.
|
||||
#[derive(Zeroize, Clone, PartialEq)]
|
||||
#[zeroize(drop)]
|
||||
pub struct PlainText(Vec<u8>);
|
||||
|
||||
impl PlainText {
|
||||
/// Instantiate self with `len` zeros.
|
||||
pub fn zero(len: usize) -> Self {
|
||||
Self(vec![0; len])
|
||||
}
|
||||
|
||||
/// The byte-length of `self`
|
||||
pub fn len(&self) -> usize {
|
||||
self.0.len()
|
||||
}
|
||||
|
||||
/// 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
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vec<u8>> for PlainText {
|
||||
fn from(vec: Vec<u8>) -> Self {
|
||||
Self(vec)
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<[u8]> for PlainText {
|
||||
fn as_ref(&self) -> &[u8] {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user