digipl
February 3, 2024, 7:57pm
7
As long as it is the client who performs the self-encryption, it is not possible for the nodes to know whether the chunk is encrypted or not.
What the nodes do, in the latest testnet, is encrypt the chunk before storing it on disk.
As for compression, self-encryption use brotli.
Brotli is a lossless data compression algorithm developed by Google. It uses a combination of the general-purpose LZ77 lossless compression algorithm, Huffman coding and 2nd-order context modelling.
Brotli is primarily used by web servers and content delivery networks to compress HTTP content, making internet websites load faster. A successor to gzip, it is supported by all major web browsers and has become increasingly popular, as it provides better compression than gzip.
Google employees Jyr...
}
/// Encrypt the chunk
pub(crate) fn encrypt_chunk(content: Bytes, pki: (Pad, Key, Iv)) -> Result<Bytes> {
let (pad, key, iv) = pki;
let mut compressed = vec![];
let enc_params = BrotliEncoderParams {
quality: COMPRESSION_QUALITY,
..Default::default()
};
let _size = brotli::BrotliCompress(
&mut Cursor::new(content.as_ref()),
&mut compressed,
&enc_params,
)
.map_err(|_| Error::Compression)?;
let encrypted = encryption::encrypt(Bytes::from(compressed), &key, &iv)?;
Ok(xor(&encrypted, &pad))
}
6 Likes