Skip to content

Commit

Permalink
feat(node): derive encrypt_details from self keypair
Browse files Browse the repository at this point in the history
  • Loading branch information
maqi committed Nov 4, 2024
1 parent 15bf53f commit 92c0a31
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ jobs:

- name: Run network tests
timeout-minutes: 25
run: cargo test --release --package sn_networking --features="open-metrics"
run: cargo test --release --package sn_networking --features="open-metrics, encrypt-records" can_store_after_restart

- name: Run protocol tests
timeout-minutes: 25
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ jobs:

- name: Run network tests
timeout-minutes: 25
run: cargo test --release --package sn_networking --features="open-metrics"
run: cargo test --release --package sn_networking --features="open-metrics, encrypt-records"

- name: Run protocol tests
timeout-minutes: 25
Expand Down
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions sn_networking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,14 @@ tracing = { version = "~0.1.26" }
xor_name = "5.0.0"
backoff = { version = "0.4.0", features = ["tokio"] }
aes-gcm-siv = "0.11.1"
hkdf = "0.12"
sha2 = "0.10"
walkdir = "~2.5.0"
strum = { version = "0.26.2", features = ["derive"] }
void = "1.0.2"

[dev-dependencies]
assert_fs = "1.0.0"
bls = { package = "blsttc", version = "8.0.1" }
# add rand to libp2p
libp2p-identity = { version = "0.2.7", features = ["rand"] }
Expand Down
9 changes: 9 additions & 0 deletions sn_networking/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ use sn_protocol::{
use sn_registers::SignedRegister;
use std::{
collections::{btree_map::Entry, BTreeMap, HashMap, HashSet},
convert::TryInto,
fmt::Debug,
fs,
io::{Read, Write},
Expand Down Expand Up @@ -389,10 +390,18 @@ impl NetworkBuilder {
source: error,
});
}
let peer_id = PeerId::from(self.keypair.public());
let encryption_seed: [u8; 16] = peer_id
.to_bytes()
.get(..16)
.expect("Cann't get encryption_seed from keypair")
.try_into()
.expect("Cann't get 16 bytes from serialised key_pair");
NodeRecordStoreConfig {
max_value_bytes: MAX_PACKET_SIZE, // TODO, does this need to be _less_ than MAX_PACKET_SIZE
storage_dir: storage_dir_path,
historic_quote_dir: root_dir.clone(),
encryption_seed,
..Default::default()
}
};
Expand Down
Loading

0 comments on commit 92c0a31

Please sign in to comment.