Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
justprosh committed Oct 10, 2023
1 parent 6203496 commit bfa9d38
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions keypair/src/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// DEALINGS IN THE SOFTWARE.

Check warning on line 19 in keypair/src/ed25519.rs

View workflow job for this annotation

GitHub Actions / lints

Diff in /home/runner/work/trust-graph/trust-graph/keypair/src/ed25519.rs

//! Ed25519 keys.
use crate::error::{DecodingError, SigningError, VerificationError};
use crate::error::{DecodingError::InvalidLength, DecodingError, SigningError, VerificationError};
use core::fmt;
use ed25519_dalek::{self as ed25519, Signer as _, Verifier as _};
use serde::{Deserialize, Serialize};
Expand All @@ -46,8 +46,7 @@ impl Keypair {
/// Decode a keypair from the format produced by `encode`,
/// zeroing the input on success.
pub fn decode(kp: &mut [u8]) -> Result<Self, DecodingError> {
let bytes = <[u8; 64]>::try_from(&*kp)
.map_err(DecodingError::InvalidLength)?;
let bytes = <[u8; 64]>::try_from(&*kp).map_err(InvalidLength)?;

ed25519::SigningKey::from_keypair_bytes(&bytes)
.map(|k| {
Expand Down Expand Up @@ -130,8 +129,7 @@ impl PublicKey {

/// Decode a public key from a byte array as produced by `encode`.
pub fn decode(bytes: &[u8]) -> Result<Self, DecodingError> {
let bytes = <[u8; 32]>::try_from(bytes)
.map_err(DecodingError::InvalidLength)?;
let bytes = <[u8; 32]>::try_from(bytes).map_err(InvalidLength)?;
ed25519::VerifyingKey::from_bytes(&bytes)
.map_err(DecodingError::Ed25519)
.map(PublicKey)
Expand Down Expand Up @@ -167,8 +165,7 @@ impl SecretKey {
/// returned.
pub fn from_bytes(mut sk_bytes: impl AsMut<[u8]>) -> Result<Self, DecodingError> {
let sk_bytes = sk_bytes.as_mut();
let secret = <[u8; 32]>::try_from(&*sk_bytes)
.map_err(DecodingError::InvalidLength)?;
let secret = <[u8; 32]>::try_from(&*sk_bytes).map_err(InvalidLength)?;
sk_bytes.zeroize();
Ok(SecretKey(secret))
}
Expand Down

0 comments on commit bfa9d38

Please sign in to comment.