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

Function create_proof

saver/src/saver_groth16.rs:83–105  ·  view source on GitHub ↗

`r` is the randomness used during the encryption

(
    circuit: C,
    r: &E::ScalarField,
    pk: &ProvingKey<E>,
    encryption_key: &EncryptionKey<E>,
    rng: &mut R,
)

Source from the content-addressed store, hash-verified

81
82/// `r` is the randomness used during the encryption
83pub 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>
90where
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`

Callers 3

encrypt_with_proofMethod · 0.70
checkFunction · 0.70
checkFunction · 0.70

Calls 2

randFunction · 0.85

Tested by 1

checkFunction · 0.56