Clippy nightly: disable owned cmp, stop comparing bool using assert_eq (#2073)

* Disable clippy warnings about comparing a newly created struct

In Sapling, we compare canonical JubJub bytes with a supplied byte array.

Since we need to perform calculations to get it into canonical form, we
need to create a newly owned object.

* Clippy: use assert rather than assert_eq on a bool
This commit is contained in:
teor 2021-04-27 22:57:45 +10:00 committed by GitHub
parent 4b948e67a7
commit 1f40498fcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -285,6 +285,8 @@ impl From<SpendingKey> for SpendAuthorizingKey {
}
impl PartialEq<[u8; 32]> for SpendAuthorizingKey {
// TODO: do we want to use constant-time comparison here?
#[allow(clippy::cmp_owned)]
fn eq(&self, other: &[u8; 32]) -> bool {
<[u8; 32]>::from(*self) == *other
}
@ -326,6 +328,8 @@ impl From<SpendingKey> for ProofAuthorizingKey {
}
impl PartialEq<[u8; 32]> for ProofAuthorizingKey {
// TODO: do we want to use constant-time comparison here?
#[allow(clippy::cmp_owned)]
fn eq(&self, other: &[u8; 32]) -> bool {
<[u8; 32]>::from(*self) == *other
}
@ -485,6 +489,8 @@ impl From<ProofAuthorizingKey> for NullifierDerivingKey {
}
impl PartialEq<[u8; 32]> for NullifierDerivingKey {
// TODO: do we want to use constant-time comparison here?
#[allow(clippy::cmp_owned)]
fn eq(&self, other: &[u8; 32]) -> bool {
<[u8; 32]>::from(*self) == *other
}
@ -776,6 +782,8 @@ impl From<(IncomingViewingKey, Diversifier)> for TransmissionKey {
}
impl PartialEq<[u8; 32]> for TransmissionKey {
// TODO: do we want to use constant-time comparison here?
#[allow(clippy::cmp_owned)]
fn eq(&self, other: &[u8; 32]) -> bool {
<[u8; 32]>::from(*self) == *other
}
@ -898,6 +906,8 @@ impl From<&EphemeralPublicKey> for [u8; 32] {
}
impl PartialEq<[u8; 32]> for EphemeralPublicKey {
// TODO: do we want to use constant-time comparison here?
#[allow(clippy::cmp_owned)]
fn eq(&self, other: &[u8; 32]) -> bool {
<[u8; 32]>::from(self) == *other
}

View File

@ -131,7 +131,7 @@ mod tests {
);
assert_eq!(user_agent, "");
assert_eq!(start_height.0, 0);
assert_eq!(relay, false);
assert!(!relay);
} else {
panic!("handshake did not send version message");
}