Fix clippy warnings (#1385)

## Issue Addressed

NA

## Proposed Changes

Fixes most clippy warnings and ignores the rest of them, see issue #1388.
This commit is contained in:
blacktemplar
2020-07-23 14:18:00 +00:00
parent ba10c80633
commit 23a8f31f83
93 changed files with 396 additions and 396 deletions

View File

@@ -60,7 +60,7 @@ type VerifySet<'a> = (
);
#[cfg(not(feature = "fake_crypto"))]
pub fn verify_signature_sets<'a>(sets: Vec<SignatureSet>) -> bool {
pub fn verify_signature_sets(sets: Vec<SignatureSet>) -> bool {
let rng = &mut rand::thread_rng();
let verify_set: Vec<VerifySet> = sets
.iter()

View File

@@ -81,7 +81,7 @@ fn derive_child_sk(parent_sk: &[u8], index: u32) -> SecretHash {
///
/// Equivalent to `HKDF_mod_r` in EIP-2333.
fn hkdf_mod_r(ikm: &[u8]) -> SecretHash {
let prk = hkdf_extract("BLS-SIG-KEYGEN-SALT-".as_bytes(), ikm);
let prk = hkdf_extract(b"BLS-SIG-KEYGEN-SALT-", ikm);
let okm = &hkdf_expand(prk, MOD_R_L);
mod_r(okm.as_bytes())
}

View File

@@ -16,6 +16,11 @@ impl PlainText {
self.0.len()
}
/// Checks whether `self` is empty
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
/// Returns a reference to the underlying bytes.
pub fn as_bytes(&self) -> &[u8] {
&self.0

View File

@@ -14,6 +14,10 @@ impl HexBytes {
pub fn len(&self) -> usize {
self.0.len()
}
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
}
impl From<Vec<u8>> for HexBytes {

View File

@@ -66,7 +66,7 @@ pub enum Prf {
impl Prf {
pub fn mac(&self, password: &[u8]) -> impl Mac {
match &self {
_hmac_sha256 => {
Prf::HmacSha256 => {
Hmac::<Sha256>::new_varkey(password).expect("Could not derive HMAC using SHA256.")
}
}

View File

@@ -409,10 +409,10 @@ fn derive_key(password: &[u8], kdf: &Kdf) -> Result<DerivedKey, Error> {
password,
params.salt.as_bytes(),
&ScryptParams::new(log2_int(params.n) as u8, params.r, params.p)
.map_err(|e| Error::ScryptInvalidParams(e))?,
.map_err(Error::ScryptInvalidParams)?,
dk.as_mut_bytes(),
)
.map_err(|e| Error::ScryptInvaidOutputLen(e))?;
.map_err(Error::ScryptInvaidOutputLen)?;
}
}