Verify that the snark proof is valid, the commitment in the ciphertext is correct, the commitment to the chunks and the combined message are equal, the chunks committed in ciphertext are same as the ones committed in the chunked commitment and all the 3 Schnorr proofs are valid.
(
&self,
challenge: &E::ScalarField,
proof: &SaverProof<E>,
ck_comm_ct: &[E::G1Affine],
ck_comm_chunks: &[E::G1Affine],
ck_comm_combined: &[E::G1Affine]
| 244 | /// to the chunks and the combined message are equal, the chunks committed in ciphertext are same |
| 245 | /// as the ones committed in the chunked commitment and all the 3 Schnorr proofs are valid. |
| 246 | pub fn verify_proof_contribution( |
| 247 | &self, |
| 248 | challenge: &E::ScalarField, |
| 249 | proof: &SaverProof<E>, |
| 250 | ck_comm_ct: &[E::G1Affine], |
| 251 | ck_comm_chunks: &[E::G1Affine], |
| 252 | ck_comm_combined: &[E::G1Affine], |
| 253 | pvk: &PreparedVerifyingKey<E>, |
| 254 | pgens: impl Into<PreparedEncryptionGens<E>>, |
| 255 | pek: impl Into<PreparedEncryptionKey<E>>, |
| 256 | pairing_checker: &mut Option<RandomizedPairingChecker<E>>, |
| 257 | resp_for_message: E::ScalarField, |
| 258 | ) -> Result<(), ProofSystemError> { |
| 259 | let pek = pek.into(); |
| 260 | let pgens = pgens.into(); |
| 261 | let expected_count = pek.supported_chunks_count()? as usize; |
| 262 | if proof.ciphertext.enc_chunks.len() != expected_count { |
| 263 | return Err(SaverError::IncompatibleEncryptionKey( |
| 264 | proof.ciphertext.enc_chunks.len(), |
| 265 | expected_count, |
| 266 | ) |
| 267 | .into()); |
| 268 | } |
| 269 | match pairing_checker { |
| 270 | Some(c) => { |
| 271 | let (a, b) = ( |
| 272 | Encryption::<E>::get_g1_for_ciphertext_commitment_pairing_checks( |
| 273 | &proof.ciphertext.X_r, |
| 274 | &proof.ciphertext.enc_chunks, |
| 275 | &proof.ciphertext.commitment, |
| 276 | ), |
| 277 | Encryption::get_g2_for_ciphertext_commitment_pairing_checks(&pek, &pgens), |
| 278 | ); |
| 279 | c.add_multiple_sources_and_target(&a, b, &PairingOutput::zero()); |
| 280 | let d = calculate_d(pvk, &proof.ciphertext)?; |
| 281 | c.add_multiple_sources_and_target( |
| 282 | &[proof.snark_proof.a, proof.snark_proof.c, d], |
| 283 | [ |
| 284 | proof.snark_proof.b.into(), |
| 285 | pvk.delta_g2_neg_pc.clone(), |
| 286 | pvk.gamma_g2_neg_pc.clone(), |
| 287 | ], |
| 288 | &PairingOutput(pvk.alpha_g1_beta_g2), |
| 289 | ); |
| 290 | } |
| 291 | None => proof |
| 292 | .ciphertext |
| 293 | .verify_commitment_and_proof(&proof.snark_proof, pvk, pek, pgens) |
| 294 | .map_err(|e| ProofSystemError::SaverProofContributionFailed(self.id as u32, e))?, |
| 295 | } |
| 296 | |
| 297 | self.verify_ciphertext_and_commitment( |
| 298 | challenge, |
| 299 | &proof.ciphertext, |
| 300 | proof.comm_combined.clone(), |
| 301 | proof.comm_chunks.clone(), |
| 302 | &proof.sp_ciphertext, |
| 303 | &proof.sp_chunks, |