mortendahl/rust-paillier

purpose of wrapping RawCiphertext via EncodedCiphertext?

haochenuw opened this issue · 1 comments

More of a question than an issue, but I was wondering what's the purpose of using EncodedCiphertext type to wrap the RawCiphertext? Also quite new to rust -- could you give pointers to help understand the syntax below? I understand that the first line is implementing the Encrypt trait, but not sure what the second and third line means.

impl<EK> Encrypt<EK, u64, EncodedCiphertext<u64>> for Paillier
where
    for<'p, 'c> Self: Encrypt<EK, RawPlaintext<'p>, RawCiphertext<'c>>,
{
                 // more code here
        }
    }
}

I personally never used the EncodedCiphertext added property over RawCiphertext (in fact when I handle ciphertexts I usually try to work with the BigInt itself).
However, in theory, the EncodedCiphertext adds another field to Rawciphertext that can be used for different purposes. In the code it is being used for "packing" which is common operation that allows to take several small messages and encrypt them together in a single ciphertext

About the code snippet: I suggest you ignore it for now. It is a way to express bounds: https://doc.rust-lang.org/stable/rust-by-example/generics/where.html