Skip to content

Commit

Permalink
simplify signature conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
showengineer committed Feb 13, 2022
1 parent 42a79b5 commit 0790ec1
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/security.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use ed25519_dalek::Verifier;
use ed25519_dalek::{PublicKey, Signature};

use std::convert::TryInto;

/// If verification failes, it will return the `ValidationError` enum.
/// If verification fails, it will return the `ValidationError` enum.
pub enum ValidationError {
/// For anything related to conversion errors
KeyConversionError {
Expand All @@ -26,15 +24,7 @@ pub fn verify_discord_message(
let signature_bytes = hex::decode(signature)
.map_err(|_| ValidationError::KeyConversionError { name: "Signature" })?;

let signature_bytes =
signature_bytes
.as_slice()
.try_into()
.map_err(|_| ValidationError::KeyConversionError {
name: "Signature Length",
})?;

let signature = Signature::from_bytes(signature_bytes).map_err(|_| {
let signature = Signature::from_bytes(signature_bytes.as_slice()).map_err(|_| {
ValidationError::KeyConversionError {
name: "From bytes conversion error",
}
Expand Down

0 comments on commit 0790ec1

Please sign in to comment.