Skip to content

Commit

Permalink
feat: re-factor tree_r_last building for external re-use
Browse files Browse the repository at this point in the history
reduce conversions in encode (@dignifiedquire)
feat: reduce conversions for CPU tree building differently
feat: use an enum return type to avoid transmute (unsafe)
fix: properly use GPU if possible
  • Loading branch information
cryptonemo committed Oct 26, 2021
1 parent 241fd49 commit 1f83fca
Show file tree
Hide file tree
Showing 6 changed files with 242 additions and 126 deletions.
8 changes: 8 additions & 0 deletions storage-proofs-core/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ impl<'a> Data<'a> {
}
}

pub fn empty() -> Self {
Data {
raw: None,
path: None,
len: 0,
}
}

pub fn len(&self) -> usize {
self.len
}
Expand Down
10 changes: 7 additions & 3 deletions storage-proofs-porep/src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ use blstrs::Scalar as Fr;
use filecoin_hashers::Domain;

pub fn encode<T: Domain>(key: T, value: T) -> T {
let mut result: Fr = value.into();
let key: Fr = key.into();
let value: Fr = value.into();
let mut result: Fr = key.into();

result += key;
encode_fr(&mut result, value);
result.into()
}

pub fn encode_fr(key: &mut Fr, value: Fr) {
*key += value;
}

pub fn decode<T: Domain>(key: T, value: T) -> T {
let mut result: Fr = value.into();
let key: Fr = key.into();
Expand Down
2 changes: 1 addition & 1 deletion storage-proofs-porep/src/stacked/vanilla/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ pub use encoding_proof::EncodingProof;
pub use graph::{StackedBucketGraph, StackedGraph, EXP_DEGREE};
pub use labeling_proof::LabelingProof;
pub use params::*;
pub use proof::{StackedDrg, TOTAL_PARENTS};
pub use proof::{StackedDrg, TreeRElementData, TOTAL_PARENTS};
Loading

0 comments on commit 1f83fca

Please sign in to comment.