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

Method encrypt_with_proof

saver/src/encryption.rs:189–206  ·  view source on GitHub ↗

Return the encryption and Groth16 proof

(
        rng: &mut R,
        message: &E::ScalarField,
        ek: &EncryptionKey<E>,
        snark_pk: &saver_groth16::ProvingKey<E>,
        chunk_bit_size: u8,
    )

Source from the content-addressed store, hash-verified

187
188 /// Return the encryption and Groth16 proof
189 pub fn encrypt_with_proof<R: RngCore>(
190 rng: &mut R,
191 message: &E::ScalarField,
192 ek: &EncryptionKey<E>,
193 snark_pk: &saver_groth16::ProvingKey<E>,
194 chunk_bit_size: u8,
195 ) -> crate::Result<(Ciphertext<E>, E::ScalarField, ark_groth16::Proof<E>)> {
196 let g_i = saver_groth16::get_gs_for_encryption(&snark_pk.pk.vk);
197 let (ct, r) = Encryption::encrypt(rng, message, ek, g_i, chunk_bit_size)?;
198 let decomposed_message = utils::decompose(message, chunk_bit_size)?
199 .into_iter()
200 .map(|m| E::ScalarField::from(m as u64))
201 .collect::<Vec<_>>();
202 let circuit =
203 BitsizeCheckCircuit::new(chunk_bit_size, None, Some(decomposed_message), true);
204 let proof = saver_groth16::create_proof(circuit, &r, snark_pk, ek, rng)?;
205 Ok((ct, r, proof))
206 }
207
208 pub fn rerandomize_ciphertext_and_proof<R: RngCore>(
209 ciphertext: Ciphertext<E>,

Callers

nothing calls this directly

Calls 5

mapMethod · 0.80
get_gs_for_encryptionFunction · 0.70
decomposeFunction · 0.70
create_proofFunction · 0.70
into_iterMethod · 0.45

Tested by

no test coverage detected