Skip to content

Commit

Permalink
Be more idiomatic.
Browse files Browse the repository at this point in the history
  • Loading branch information
porcuquine committed Sep 1, 2020
1 parent c23e10f commit 866d8d2
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions storage-proofs/core/src/multi_proof.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use bellperson::groth16;

use crate::error::Result;
use anyhow::Context;
use anyhow::{ensure, Context};
use paired::bls12_381::Bls12;
use rayon::prelude::*;
use std::io::{self, Read, Write};
Expand Down Expand Up @@ -45,11 +45,19 @@ impl<'a> MultiProof<'a> {
) -> Result<Self> {
let num_proofs = partitions.unwrap_or(1);

let proofs = (0..num_proofs)
.into_par_iter()
.map(|i| groth16::Proof::read(&proof_bytes[GROTH_PROOF_SIZE * i..]))
let proofs = proof_bytes
.par_chunks(GROTH_PROOF_SIZE)
.take(num_proofs)
.map(groth16::Proof::read)
.collect::<io::Result<Vec<_>>>()?;

ensure!(
num_proofs == proofs.len(),
"expected {} proofs but found only {}",
num_proofs,
proofs.len()
);

Ok(Self::new(proofs, verifying_key))
}

Expand Down

0 comments on commit 866d8d2

Please sign in to comment.