Merge branch 'jf/invite' of github.com:uqbar-dao/uqbar into jf/invite

This commit is contained in:
realisation 2023-10-16 17:45:03 -04:00
commit 1b9c773a55
2 changed files with 12 additions and 14 deletions

View File

@ -66,11 +66,7 @@ pub fn encode_keyfile(
.unwrap()
}
pub fn decode_keyfile(
keyfile: Vec<u8>,
password: &str,
) -> Result<Keyfile, &'static str> {
pub fn decode_keyfile(keyfile: Vec<u8>, password: &str) -> Result<Keyfile, &'static str> {
let (username, routers, salt, key_enc, jtw_enc, file_enc) =
bincode::deserialize::<(String, Vec<String>, Vec<u8>, Vec<u8>, Vec<u8>, Vec<u8>)>(&keyfile)
.map_err(|_| "failed to deserialize keyfile")?;
@ -92,16 +88,19 @@ pub fn decode_keyfile(
let jwt_nonce = generic_array::GenericArray::from_slice(&jtw_enc[..12]);
let file_nonce = generic_array::GenericArray::from_slice(&file_enc[..12]);
let serialized_networking_keypair: Vec<u8> = cipher.decrypt(net_nonce, &key_enc[12..])
let serialized_networking_keypair: Vec<u8> = cipher
.decrypt(net_nonce, &key_enc[12..])
.map_err(|_| "failed to decrypt networking keys")?;
let networking_keypair = signature::Ed25519KeyPair::from_pkcs8(&serialized_networking_keypair)
.map_err(|_| "failed to parse networking keys")?;
let jwt_secret_bytes: Vec<u8> = cipher.decrypt(jwt_nonce, &jtw_enc[12..])
let jwt_secret_bytes: Vec<u8> = cipher
.decrypt(jwt_nonce, &jtw_enc[12..])
.map_err(|_| "failed to decrypt jwt secret")?;
let file_key: Vec<u8> = cipher.decrypt(file_nonce, &file_enc[12..])
let file_key: Vec<u8> = cipher
.decrypt(file_nonce, &file_enc[12..])
.map_err(|_| "failed to decrypt file key")?;
Ok(Keyfile {
@ -111,7 +110,6 @@ pub fn decode_keyfile(
jwt_secret_bytes,
file_key,
})
}
/// # Returns

View File

@ -1,10 +1,10 @@
use crate::kernel::component::uq_process::types as wit;
use ring::signature;
use serde::{Deserialize, Serialize};
use std::{
collections::{HashMap, HashSet},
sync::Arc,
};
use ring::signature;
use thiserror::Error;
use tokio::sync::RwLock;