While you do not need to fully understand RLWE to use Concrete, it is useful to know they exist, as they will be used under the hood to perform bootstrapping (which we will learn about later).
RLWE stands for Ring Learning With Errors and refers to the extension of LWE over the ring of polynomials with coefficients in a modular integer ring. It is also a computational problem conjectured to be hard to solve. RLWE enable packing multiple ciphertexts into a single polynomial, enabling SIMD-like homomorphic operations.
Since RLWE is an extension of LWE, you can extract one of the RLWE ciphertext polynomial coefficient as an LWE ciphertext.
RLWE instances are 2-dimensional: they hold a vector of ciphertexts, in which each coefficient is itself a plaintext. Thus, when extracting an LWE, we need to both specify the coefficient we want as well as the ciphertext from which to extract that coefficient. This is done via the
// extracting the 3rd coefficient from the 1st ciphertext// ciphertexts and coefficients are zero-indexedlet lwe_ciphertext: VectorLWE = rlwe_ciphertext.extract_1_lwe(2, 0)?;
RLWESecretKey instance into an
LWESecretKey is done using
// convert the RLWE secret key into an LWE secret keylet lwe_sk = rlwe_sk.to_lwe_secret_key();
Sometimes, you might need to do the opposite operation, and convert an LWE secret key into an RLWE secret key. This works almost the same, the only difference being that you have to specify the polynomial size when you use the
to_rlwe_secret_key method: This assumes that the LWE dimension is a multiple of (i.e,, the degree of the polynomial).
// convert the LWE secret key into an RLWE secret keylet rlwe_sk = lwe_sk.to_rlwe_secret_key(512)?;