Skip to content

Commit

Permalink
fix: snapshot blocks are encrypted now
Browse files Browse the repository at this point in the history
  • Loading branch information
organizedgrime committed Nov 14, 2023
1 parent 354cda1 commit b895c03
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions wnfs/src/private/node/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,11 @@ impl PrivateNodeHeader {
store: &impl BlockStore,
_rng: &mut impl RngCore,
) -> Result<Cid> {
let _snapshot_key = self.derive_temporal_key().derive_snapshot_key();
let snapshot_key = self.derive_temporal_key().derive_snapshot_key();
let tuple = (self.inumber, self.bare_name.clone());
let cbor_bytes = serde_ipld_dagcbor::to_vec(&tuple)?;
// let ciphertext = snapshot_key.encrypt(&cbor_bytes, rng)?;
store.put_block(cbor_bytes, IpldCodec::Raw).await
let ciphertext = TemporalKey(snapshot_key.0).key_wrap_encrypt(&cbor_bytes)?;
store.put_block(ciphertext, IpldCodec::Raw).await
}

/// Loads a private node header from a given CID linking to the ciphertext block
Expand All @@ -247,11 +247,11 @@ impl PrivateNodeHeader {

pub(crate) async fn load_snapshot(
cid: &Cid,
_snapshot_key: &SnapshotKey,
snapshot_key: &SnapshotKey,
store: &impl BlockStore,
) -> Result<PrivateNodeHeader> {
let cbor_bytes = store.get_block(cid).await?;
// let cbor_bytes = snapshot_key.decrypt(&ciphertext)?;
let ciphertext = store.get_block(cid).await?;
let cbor_bytes = TemporalKey(snapshot_key.0.to_owned()).key_wrap_decrypt(&ciphertext)?;
let tuple: ([u8; 32], BloomFilter<256, 30>) = serde_ipld_dagcbor::from_slice(&cbor_bytes)?;
let header = PrivateNodeHeader {
inumber: tuple.0,
Expand Down

0 comments on commit b895c03

Please sign in to comment.