Add method to calculate the underlying number of bytes

Required for part of attestation validation logic
This commit is contained in:
Alex Stokes
2018-11-20 10:12:49 -08:00
committed by mjkeating
parent f611602235
commit 38d9d7ac92
2 changed files with 23 additions and 1 deletions

View File

@@ -199,6 +199,10 @@ where
}
}
fn bytes_for_bits(bits: usize) -> usize {
(bits.saturating_sub(1) / 8) + 1
}
impl From<ParentHashesError> for AttestationValidationError {
fn from(e: ParentHashesError) -> Self {
match e {
@@ -243,4 +247,4 @@ impl From<SignatureVerificationError> for AttestationValidationError {
=> AttestationValidationError::OutOfBoundsBitfieldIndex,
}
}
}
}