diff --git a/src/error.rs b/src/error.rs index b9a922d..af5dc63 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,4 +1,3 @@ - use thiserror::Error; #[derive(Clone, Error, Debug, PartialEq)] @@ -41,5 +40,5 @@ pub enum Error { // UTF8 Decode #[error("UTF8 Decode: {0}")] - Utf8Decode(#[from] std::string::FromUtf8Error) + Utf8Decode(#[from] std::string::FromUtf8Error), } diff --git a/src/lib.rs b/src/lib.rs index 7b6d2fe..0dbebcc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -51,10 +51,7 @@ pub fn get_conversation_key( ssp.try_into().unwrap() } -fn get_message_keys( - conversation_key: &[u8; 32], - salt: &[u8; 32], -) -> Result { +fn get_message_keys(conversation_key: &[u8; 32], salt: &[u8; 32]) -> Result { let hk = Hkdf::::new(Some(&salt[..]), conversation_key); let mut message_keys: MessageKeys = MessageKeys::zero(); if let Err(_) = hk.expand("nip44-v2".as_bytes(), &mut message_keys.0) { @@ -130,10 +127,7 @@ fn encrypt_inner( } /// Decrypt the base64 encrypted contents with a conversation key -pub fn decrypt( - conversation_key: &[u8; 32], - base64_ciphertext: &str, -) -> Result { +pub fn decrypt(conversation_key: &[u8; 32], base64_ciphertext: &str) -> Result { if base64_ciphertext.as_bytes()[0] == b'#' { return Err(Error::UnsupportedFutureVersion); } diff --git a/src/tests.rs b/src/tests.rs index 9e9ea0c..53c1fff 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -328,7 +328,11 @@ pub fn test_invalid_pub_test_vectors() { // Test decryption fails let result = decrypt(&conversation_key, &vector.ciphertext); - assert!(result.is_err(), "Should not have decrypted: {}", vector.note); + assert!( + result.is_err(), + "Should not have decrypted: {}", + vector.note + ); let err = result.unwrap_err(); assert_eq!(err, vector.error, "Plaintext was {}", vector.plaintext); }