From 0536135fda3ae1bc90a5666d3429e438e29410ad Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Mon, 15 Jun 2020 22:30:29 +0200 Subject: [PATCH] consistent use of porep_id and endianess --- storage-proofs/porep/src/stacked/circuit/proof.rs | 3 +-- storage-proofs/porep/src/stacked/vanilla/cache.rs | 9 ++++++--- storage-proofs/porep/src/stacked/vanilla/graph.rs | 2 +- storage-proofs/porep/src/stacked/vanilla/proof.rs | 3 +-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/storage-proofs/porep/src/stacked/circuit/proof.rs b/storage-proofs/porep/src/stacked/circuit/proof.rs index 4ab808f355..0430bcc5e0 100644 --- a/storage-proofs/porep/src/stacked/circuit/proof.rs +++ b/storage-proofs/porep/src/stacked/circuit/proof.rs @@ -443,11 +443,10 @@ mod tests { assert_ne!(data, copied, "replication did not change data"); let seed = rng.gen(); - let arbitrary_porep_id = [44; 32]; let pub_inputs = PublicInputs::<::Domain, ::Domain> { replica_id: replica_id.into(), - porep_id: arbitrary_porep_id, + porep_id: [32; 32], seed, tau: Some(tau.into()), k: None, diff --git a/storage-proofs/porep/src/stacked/vanilla/cache.rs b/storage-proofs/porep/src/stacked/vanilla/cache.rs index a96630bd77..acede8be27 100644 --- a/storage-proofs/porep/src/stacked/vanilla/cache.rs +++ b/storage-proofs/porep/src/stacked/vanilla/cache.rs @@ -1,7 +1,7 @@ use std::path::PathBuf; use anyhow::{bail, ensure, Context}; -use byteorder::{BigEndian, ByteOrder}; +use byteorder::{ByteOrder, LittleEndian}; use log::info; use rayon::prelude::*; use sha2::{Digest, Sha256}; @@ -83,7 +83,7 @@ impl CacheData { let end = start + DEGREE * NODE_BYTES; let mut res = [0u32; DEGREE]; - BigEndian::read_u32_into(&self.data[start..end], &mut res); + LittleEndian::read_u32_into(&self.data[start..end], &mut res); res } @@ -199,7 +199,7 @@ impl ParentCache { .parents(node, &mut parents[..BASE_DEGREE])?; graph.generate_expanded_parents(node, &mut parents[BASE_DEGREE..]); - BigEndian::write_u32_into(&parents, entry); + LittleEndian::write_u32_into(&parents, entry); Ok(()) })?; @@ -254,6 +254,9 @@ where hasher.input(H::name()); hasher.input(graph.identifier()); + for key in &graph.feistel_keys { + hasher.input(key.to_le_bytes()); + } hasher.input(cache_entries.to_le_bytes()); let h = hasher.result(); PathBuf::from(PARENT_CACHE_DIR).join(format!( diff --git a/storage-proofs/porep/src/stacked/vanilla/graph.rs b/storage-proofs/porep/src/stacked/vanilla/graph.rs index ffb8869449..90361016c3 100644 --- a/storage-proofs/porep/src/stacked/vanilla/graph.rs +++ b/storage-proofs/porep/src/stacked/vanilla/graph.rs @@ -38,7 +38,7 @@ where { expansion_degree: usize, base_graph: G, - feistel_keys: [feistel::Index; 4], + pub(crate) feistel_keys: [feistel::Index; 4], feistel_precomputed: FeistelPrecomputed, id: String, _h: PhantomData, diff --git a/storage-proofs/porep/src/stacked/vanilla/proof.rs b/storage-proofs/porep/src/stacked/vanilla/proof.rs index 703c207097..06fbeaff65 100644 --- a/storage-proofs/porep/src/stacked/vanilla/proof.rs +++ b/storage-proofs/porep/src/stacked/vanilla/proof.rs @@ -1492,11 +1492,10 @@ mod tests { assert_ne!(data, copied, "replication did not change data"); let seed = rng.gen(); - let arbitrary_porep_id = [92; 32]; let pub_inputs = PublicInputs::<::Domain, ::Domain> { replica_id, - porep_id: arbitrary_porep_id, + porep_id: [32; 32], seed, tau: Some(tau), k: None,