derive key of UserStorage

master
Niko PLP 1 month ago
parent 3926f1f2e4
commit 6852d56bbc
  1. 21
      ng-verifier/src/verifier.rs

@ -25,6 +25,7 @@ use async_std::stream::StreamExt;
use async_std::sync::{Mutex, RwLockReadGuard}; use async_std::sync::{Mutex, RwLockReadGuard};
use futures::channel::mpsc; use futures::channel::mpsc;
use futures::SinkExt; use futures::SinkExt;
use ng_repo::utils::derive_key;
use sbbf_rs_safe::Filter; use sbbf_rs_safe::Filter;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use web_time::SystemTime; use web_time::SystemTime;
@ -2321,21 +2322,21 @@ impl Verifier {
let mut path_user = path.clone(); let mut path_user = path.clone();
path_user.push("user"); path_user.push("user");
create_dir_all(path_user.clone()).unwrap(); create_dir_all(path_user.clone()).unwrap();
let oxi_key = derive_key("NextGraph OxiGraph BLAKE3 key", &config.user_master_key);
let user_storage_key =
derive_key("NextGraph UserStorage BLAKE3 key", &config.user_master_key);
( (
// FIXME BIG TIME: we are reusing the same encryption key here. // FIXME: we are using 2 derived keys here.
// this is very temporary, until we remove the code in oxi_rocksdb of oxigraph, // this is temporary, until we remove the code in oxi_rocksdb of oxigraph,
// and have oxigraph use directly the UserStorage // and have oxigraph use directly the UserStorage
Some( Some(
ng_oxigraph::oxigraph::store::Store::open_with_key( ng_oxigraph::oxigraph::store::Store::open_with_key(path_oxi, oxi_key)
path_oxi,
config.user_master_key,
)
.map_err(|e| NgError::OxiGraphError(e.to_string()))?, .map_err(|e| NgError::OxiGraphError(e.to_string()))?,
), ),
Some(Box::new(RocksDbUserStorage::open( Some(
&path_user, Box::new(RocksDbUserStorage::open(&path_user, user_storage_key)?)
config.user_master_key, as Box<dyn UserStorage>,
)?) as Box<dyn UserStorage>), ),
Some(block_storage), Some(block_storage),
) )
} }

Loading…
Cancel
Save