MCPcopy Create free account
hub / github.com/docknetwork/crypto / encrypt_alt

Method encrypt_alt

saver/src/encryption.rs:254–273  ·  view source on GitHub ↗

Same as `Self::encrypt` but outputs sum `r*X_1 + r*X_2 + .. + r*X_n` as well XXX: Is this secure?

(
        rng: &mut R,
        message: &E::ScalarField,
        ek: &EncryptionKey<E>,
        g_i: &[E::G1Affine],
        chunk_bit_size: u8,
    )

Source from the content-addressed store, hash-verified

252 /// Same as `Self::encrypt` but outputs sum `r*X_1 + r*X_2 + .. + r*X_n` as well
253 // XXX: Is this secure?
254 pub fn encrypt_alt<R: RngCore>(
255 rng: &mut R,
256 message: &E::ScalarField,
257 ek: &EncryptionKey<E>,
258 g_i: &[E::G1Affine],
259 chunk_bit_size: u8,
260 ) -> crate::Result<(CiphertextAlt<E>, E::ScalarField)> {
261 let decomposed = utils::decompose(message, chunk_bit_size)?;
262 let (mut ct, r) = Self::encrypt_decomposed_message(rng, decomposed, ek, g_i)?;
263 let x_r_sum = ek.X.iter().fold(E::G1::zero(), |a, &b| a.add(b)).mul(r);
264 Ok((
265 CiphertextAlt {
266 X_r: ct.remove(0),
267 commitment: ct.remove(ct.len() - 1),
268 enc_chunks: ct,
269 X_r_sum: x_r_sum.into_affine(),
270 },
271 r,
272 ))
273 }
274
275 /// Same as `Self::encrypt_alt` but takes the SNARK verification key instead of the generators used for Elgamal encryption
276 pub fn encrypt_alt_given_snark_vk<R: RngCore>(

Callers

nothing calls this directly

Calls 6

mulMethod · 0.80
decomposeFunction · 0.70
iterMethod · 0.45
addMethod · 0.45
removeMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected