change cost paramters of wallet creation

pull/19/head
Niko PLP 6 months ago
parent 07c742c202
commit dd826b5fff
  1. 6
      ng-app/src/App.svelte
  2. 1
      ng-verifier/src/commits/mod.rs
  3. 14
      ng-verifier/src/verifier.rs
  4. 7
      ng-wallet/src/lib.rs
  5. 2
      ng-wallet/src/types.rs
  6. 6
      ngaccount/src/main.rs
  7. 12
      ngcli/src/main.rs
  8. 2
      ngd/src/cli.rs

@ -106,13 +106,13 @@
} else {
// ON WEB CLIENTS
window.addEventListener("storage", async (event) => {
console.log("localStorage event", event);
//console.log("localStorage event", event);
if (event.storageArea != localStorage) return;
if (event.key === "ng_wallets") {
console.log("localStorage", JSON.stringify($wallets));
//console.log("localStorage", JSON.stringify($wallets));
await ng.wallets_reload();
wallets.set(await ng.get_wallets());
console.log("localStorage after", JSON.stringify($wallets));
//console.log("localStorage after", JSON.stringify($wallets));
}
});
wallets.set(await ng.get_wallets());

@ -122,6 +122,7 @@ impl CommitVerifier for RootBranch {
branches: branches.into_iter().collect(),
opened_branches: HashMap::new(),
};
verifier.populate_topics(&repo);
let _repo_ref = verifier.add_repo_and_save(repo);
}
}

@ -295,11 +295,13 @@ impl Verifier {
Arc::clone(&repo.store),
);
let store = Arc::clone(&repo.store);
self.populate_topics(&repo);
self.add_repo_without_saving(repo);
for repo_id in repos {
//log_info!("LOADING REPO: {}", repo_id);
let repo = user_storage.load_repo(repo_id, Arc::clone(&store))?;
self.populate_topics(&repo);
self.add_repo_without_saving(repo);
}
}
@ -1165,7 +1167,7 @@ impl Verifier {
return;
}
let new_heads = new_heads.unwrap();
log_info!("NEW HEADS {} {:?}", branch, new_heads);
//log_info!("NEW HEADS {} {:?}", branch, new_heads);
if let Some(user_storage) = self.user_storage_if_persistent() {
let _ = user_storage.update_branch_current_head(repo_id, branch, new_heads);
}
@ -1852,7 +1854,6 @@ impl Verifier {
log_info!("SENDING {} EVENTS FOR OUTBOX", events_to_replay.len());
for e in events_to_replay {
let files = e.event.file_ids();
log_info!("HAS FILE {:?}", files);
if !files.is_empty() {
let (repo_id, branch_id) = self
.topics
@ -2038,7 +2039,7 @@ impl Verifier {
self.add_repo_(repo);
}
fn add_repo_(&mut self, repo: Repo) -> &Repo {
pub(crate) fn populate_topics(&mut self, repo: &Repo) {
for (branch_id, info) in repo.branches.iter() {
let overlay_id: OverlayId = repo.store.inner_overlay();
let topic_id = info.topic.clone();
@ -2047,8 +2048,11 @@ impl Verifier {
let res = self
.topics
.insert((overlay_id, topic_id), (repo_id, branch_id));
assert_eq!(res, None);
}
}
fn add_repo_(&mut self, repo: Repo) -> &Repo {
//self.populate_topics(&repo);
let repo_ref = self.repos.entry(repo.id).or_insert(repo);
repo_ref
}
@ -2143,6 +2147,7 @@ impl Verifier {
private,
)?;
let repo = self.complete_site_store(store_repo, repo)?;
self.populate_topics(&repo);
self.new_events_with_repo(proto_events, &repo).await?;
let repo_ref = self.add_repo_and_save(repo);
Ok(repo_ref)
@ -2164,6 +2169,7 @@ impl Verifier {
false,
false,
)?;
self.populate_topics(&repo);
self.new_events_with_repo(proto_events, &repo).await?;
let repo_ref = self.add_repo_and_save(repo);
Ok(repo_ref)

@ -285,7 +285,7 @@ pub fn dec_encrypted_block(
}
// FIXME: An important note on the cost parameters !!!
// here are set to quite high values because the code gets optimized (unfortunately) so the cost params take that into account.
// here they are set to quite high values because the code gets optimized (unfortunately) so the cost params take that into account.
// on native apps in debug mode (dev mode), the rust code is not optimized and we get a timing above 1 min, which is way too much
// once compiled for release (prod), the timing goes down to 8 sec on native apps because of the Rust optimization.
// on the WASM32 target, the wasm-pack has optimization disabled (wasm-opt = false) but we suspect the optimization happens on the V8 runtime, in the browser or node.
@ -296,8 +296,8 @@ pub fn dec_encrypted_block(
// we haven't test it yet. https://community.bitwarden.com/t/recommended-settings-for-argon2/50901/16?page=4
pub fn derive_key_from_pass(mut pass: Vec<u8>, salt: [u8; 16], wallet_id: WalletId) -> [u8; 32] {
let params = ParamsBuilder::new()
.m_cost(100 * 1024)
.t_cost(24)
.m_cost(20 * 1024)
.t_cost(30)
.p_cost(1)
.data(AssociatedData::new(wallet_id.slice()).unwrap())
.output_len(32)
@ -742,7 +742,6 @@ pub async fn create_wallet_second_step_v0(
peer_id: PubKey::nil(),
nonce: 0,
encrypted,
test: None,
};
let ser_wallet = serde_bare::to_vec(&wallet_content).unwrap();

@ -649,8 +649,6 @@ pub struct WalletContentV0 {
// WalletLog content encrypted with XChaCha20Poly1305, AD = timestamp and walletID
#[serde(with = "serde_bytes")]
pub encrypted: Vec<u8>,
pub test: Option<String>,
}
/// Wallet Log V0

@ -195,7 +195,7 @@ async fn main() -> anyhow::Result<()> {
let admin_key: PrivKey = admin_user.as_str().try_into().map_err(|_| {
anyhow!(
"NG_ACCOUNT_ADMIN is invalid. It should be a base64-url encoded serde serialization of a [u8; 32] of the private key for an admin user. cannot start"
"NG_ACCOUNT_ADMIN is invalid. It should be a base64-url encoded serde serialization of PrivKey for an admin user. cannot start"
)
})?;
@ -204,7 +204,7 @@ async fn main() -> anyhow::Result<()> {
let local_peer_key: PrivKey = local_peer_privkey.as_str().try_into().map_err(|_| {
anyhow!(
"NG_ACCOUNT_LOCAL_PEER_KEY is invalid. It should be a base64-url encoded serde serialization of a [u8; 32] of the private key for the peerId. cannot start"
"NG_ACCOUNT_LOCAL_PEER_KEY is invalid. It should be a base64-url encoded serde serialization of PrivKey for the peerId. cannot start"
)
})?;
@ -231,7 +231,7 @@ async fn main() -> anyhow::Result<()> {
let peer_id: PubKey = addr[2].try_into().map_err(|_| {
anyhow!(
"NG_ACCOUNT_SERVER is invalid. format is IP,PORT,PEER_ID.
The PEER_ID is invalid. It should be a base64-url encoded serde serialization of a [u8; 32]. cannot start"
The PEER_ID is invalid. It should be a base64-url encoded serde serialization of a PubKey. cannot start"
)
})?;

@ -167,7 +167,7 @@ async fn main_inner() -> Result<(), NgcliError> {
.default_value(".ng"))
.arg(
arg!(
-k --key <KEY> "Master key of the client. Should be a base64-url encoded serde serialization of a [u8; 32].
-k --key <KEY> "Master key of the client. Should be a base64-url encoded serde serialization of PrivKey.
If not provided, a new key will be generated for you"
)
.required(false)
@ -175,8 +175,8 @@ async fn main_inner() -> Result<(), NgcliError> {
)
.arg(
arg!(
-u --user <USER_PRIVKEY> "Client ID to use to connect to the server. Should be a base64-url encoded serde
serialization of a [u8; 32] representing the user private key"
-u --user <USER_PRIVKEY> "User ID to use to connect to the server. Should be a base64-url encoded serde
serialization of a PrivKey representing the user private key"
)
.required(false)
.env("NG_CLIENT_USER"),
@ -185,7 +185,7 @@ async fn main_inner() -> Result<(), NgcliError> {
arg!(
-s --server <IP_PORT_PEER_ID> "Server to connect to. IP can be IpV4 or IPv6, followed by a
comma and port as u16 and another comma and PEER_ID
should be a base64-url encoded serde serialization of a [u8; 32]"
should be a base64-url encoded serde serialization of a PubKey"
)
.required(false)
.env("NG_CLIENT_SERVER"),
@ -363,7 +363,7 @@ async fn main_inner() -> Result<(), NgcliError> {
})?;
let peer_id: PubKey = addr[2].try_into().map_err(|_| {
NgcliError::OtherConfigErrorStr(
"NG_CLIENT_SERVER or the --server option is invalid. format is IP,PORT,PEER_ID. The PEER_ID is invalid. It should be a base64-url encoded serde serialization of a [u8; 32]."
"NG_CLIENT_SERVER or the --server option is invalid. format is IP,PORT,PEER_ID. The PEER_ID is invalid. It should be a base64-url encoded serde serialization of a PubKey."
)
})?;
if config.is_some() {
@ -386,7 +386,7 @@ async fn main_inner() -> Result<(), NgcliError> {
if let Some(user) = matches.get_one::<String>("user") {
let privkey: PrivKey = user.as_str().try_into().map_err(|_| {
NgcliError::OtherConfigErrorStr(
"NG_CLIENT_USER or the --user option is invalid. It should be a base64-url encoded serde serialization of a [u8; 32] of a private key for a user.",
"NG_CLIENT_USER or the --user option is invalid. It should be a base64-url encoded serde serialization of a PrivKey for a user.",
)
})?;
if config.is_some() {

@ -27,7 +27,7 @@ pub(crate) struct Cli {
#[arg(short, long, default_value = ".ng", value_name("PATH"))]
pub base: String,
/// Master key of the server. Should be a base64-url encoded serde serialization of a [u8; 32]. if not provided, a new key will be generated for you
/// Master key of the server. Should be a base64-url encoded serde serialization of a PrivKey. if not provided, a new key will be generated for you
#[arg(short, long, env = "NG_SERVER_KEY")]
pub key: Option<String>,

Loading…
Cancel
Save