pub fn decrypt(cipher_key: &CipherKey, cipher_text: &[u8]) -> Result<Vec<u8>, DhtOutboundError> {
    if cipher_text.len() < size_of::<Nonce>() {
        return Err(DhtOutboundError::CipherError(
            "Cipher text is not long enough to include nonce".to_string(),
        ));
    }

    let (nonce, cipher_text) = cipher_text.split_at(size_of::<Nonce>());
    let nonce = Nonce::from_slice(nonce);
    let mut cipher_text = cipher_text.to_vec();

    let mut cipher = ChaCha20::new(&cipher_key.0, nonce);
    cipher.apply_keystream(cipher_text.as_mut_slice());
    Ok(cipher_text)
}
/// Decrypts cipher text using ChaCha20 stream cipher given the cipher key and cipher text with integral nonce.
Decrypts cipher text using ChaCha20 stream cipher given the cipher key and cipher text with integral nonce.
Decrypts cipher text using ChaCha20 stream cipher given the cipher key and cipher text with integral nonce .
pub fn decrypt(cipher_key: &CipherKey, cipher_text: &[u8]) -> Result<Vec<u8>, DhtOutboundError> {
    if cipher_text.len() < size_of::<Nonce>() {
        return Err(DhtOutboundError::CipherError(
            "Cipher text is not long enough to include nonce".to_string(),
        ));
    }
    let (nonce, cipher_text) = cipher_text.split_at(size_of::<Nonce>());
    let nonce = Nonce::from_slice(nonce);
    let mut cipher_text = cipher_text.to_vec();
    let mut cipher = ChaCha20::new(&cipher_key.0, nonce);
    cipher.apply_keystream(cipher_text.as_mut_slice());
    Ok(cipher_text)
}
pub fn decrypt ( cipher_key : & CipherKey , cipher_text : & [ u8 ] ) -> Result < Vec < u8 > , DhtOutboundError > { if cipher_text . len ( ) < size_of :: < Nonce > ( ) { return Err ( DhtOutboundError :: CipherError ( " " . to_string ( ) , ) ) ; } let ( nonce , cipher_text ) = cipher_text . split_at ( size_of :: < Nonce > ( ) ) ; let nonce = Nonce :: from_slice ( nonce ) ; let mut cipher_text = cipher_text . to_vec ( ) ; let mut cipher = ChaCha20 :: new ( & cipher_key . 0 , nonce ) ; cipher . apply_keystream ( cipher_text . as_mut_slice ( ) ) ; Ok ( cipher_text ) }
Decrypts cipher text using ChaCha20 stream cipher given the cipher key and cipher text with integral nonce.
Decrypts cipher text using ChaCha20 stream cipher given the cipher key and cipher text with integral nonce .
cipher_key
&CipherKey
cipher_text
&[u8]
cipher_key
&CipherKey
cipher_text
&[u8]