Skip to content

Commit

Permalink
refactor: the non-synth porep does not require comm_r
Browse files Browse the repository at this point in the history
The non-Synthetic PoRep doesn't require comm_r as an input. Hence call the
`derive_porep()` function directly. This renders the `derive()` function
unused.
  • Loading branch information
vmx committed Oct 9, 2023
1 parent 2779a36 commit 041b0ae
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 48 deletions.
44 changes: 1 addition & 43 deletions storage-proofs-porep/src/stacked/vanilla/challenges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,29 +65,7 @@ impl LayerChallenges {
}

/// Returns the porep challenges for partition `k`.
pub fn derive<D: Domain>(
&self,
sector_nodes: usize,
replica_id: &D,
comm_r: &D,
seed: &[u8; 32],
k: u8,
) -> Vec<usize> {
assert!(sector_nodes > 2, "Too few sector_nodes: {}", sector_nodes);
if self.use_synthetic {
trace!(
"deriving porep challenges from synthetic challenges (k = {})",
k,
);
self.derive_porep_synth(sector_nodes, replica_id, comm_r, seed, k)
} else {
trace!("deriving porep challenges (k = {})", k);
self.derive_porep(sector_nodes, replica_id, seed, k)
}
}

/// Returns the porep challenges for partition `k`.
fn derive_porep<D: Domain>(
pub(crate) fn derive_porep<D: Domain>(
&self,
sector_nodes: usize,
replica_id: &D,
Expand All @@ -111,26 +89,6 @@ impl LayerChallenges {
.collect()
}

/// Returns the porep challenges for partition `k` taken from the synthetic challenges.
fn derive_porep_synth<D: Domain>(
&self,
sector_nodes: usize,
replica_id: &D,
comm_r: &D,
seed: &[u8; 32],
k: u8,
) -> Vec<usize> {
assert!(self.use_synthetic);
let partition_challenge_count = self.challenges_count_all();
let replica_id: Fr = (*replica_id).into();
let comm_r: Fr = (*comm_r).into();
SynthChallenges::default(sector_nodes, &replica_id, &comm_r).gen_porep_partition_challenges(
partition_challenge_count,
seed,
k as usize,
)
}

/// Returns the synthetic challenge indexes of the porep challenges for partition `k`.
pub fn derive_synth_indexes<D: Domain>(
&self,
Expand Down
2 changes: 1 addition & 1 deletion storage-proofs-porep/src/stacked/vanilla/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl<T: Domain, S: Domain> PublicInputs<T, S> {
.unwrap_or(T::default());

if let Some(seed) = self.seed.as_ref() {
layer_challenges.derive(sector_nodes, &self.replica_id, &comm_r, seed, k as u8)
layer_challenges.derive_porep(sector_nodes, &self.replica_id, seed, k as u8)
} else if k == 0 {
layer_challenges.derive_synthetic(sector_nodes, &self.replica_id, &comm_r)
} else {
Expand Down
5 changes: 1 addition & 4 deletions storage-proofs-porep/src/stacked/vanilla/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,17 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> StackedDrg<'a, Tr
} else {
info!("generating non-synthetic vanilla proofs");

let comm_r = pub_inputs.tau.as_ref().expect("tau is set").comm_r;
let seed = pub_inputs
.seed
.expect("seed must be set for non-synthetic vanilla proofs");

(0..partition_count)
.map(|k| {
trace!("proving partition {}/{}", k + 1, partition_count);

// Derive the set of challenges we are proving over.
let challenges = layer_challenges.derive(
let challenges = layer_challenges.derive_porep(
graph.size(),
&pub_inputs.replica_id,
&comm_r,
&seed,
k as u8,
);
Expand Down

0 comments on commit 041b0ae

Please sign in to comment.