`r` is the randomness used during the encryption
(
circuit: C,
r: &E::ScalarField,
pk: &ProvingKey<E>,
encryption_key: &EncryptionKey<E>,
rng: &mut R,
)
| 81 | |
| 82 | /// `r` is the randomness used during the encryption |
| 83 | pub fn create_proof<E, C, R>( |
| 84 | circuit: C, |
| 85 | r: &E::ScalarField, |
| 86 | pk: &ProvingKey<E>, |
| 87 | encryption_key: &EncryptionKey<E>, |
| 88 | rng: &mut R, |
| 89 | ) -> Result<Proof<E>, SaverError> |
| 90 | where |
| 91 | E: Pairing, |
| 92 | C: ConstraintSynthesizer<E::ScalarField>, |
| 93 | R: Rng, |
| 94 | { |
| 95 | let t = E::ScalarField::rand(rng); |
| 96 | let s = E::ScalarField::rand(rng); |
| 97 | let mut proof = Groth16::<E>::create_proof_with_reduction(circuit, &pk.pk, t, s)?; |
| 98 | |
| 99 | // proof.c = proof.c + r * P_2 |
| 100 | let mut c = proof.c.into_group(); |
| 101 | c.add_assign(encryption_key.P_2.mul_bigint(r.into_bigint())); |
| 102 | proof.c = c.into_affine(); |
| 103 | |
| 104 | Ok(proof) |
| 105 | } |
| 106 | |
| 107 | /// Randomize the Groth16 proof as per algorithm 2 of the paper. Can alternatively use |
| 108 | /// `rerandomize_proof` from `ark_groth16` |