diff --git a/services/identity/src/config.rs b/services/identity/src/config.rs index a0f4e9751..d9492dd17 100644 --- a/services/identity/src/config.rs +++ b/services/identity/src/config.rs @@ -1,35 +1,39 @@ -use opaque_ke::{errors::PakeError, keypair::Key}; +use curve25519_dalek::ristretto::RistrettoPoint; +use opaque_ke::{errors::PakeError, keypair::KeyPair}; use std::{env, fs, io, path::Path}; -#[derive(Default, Debug)] +#[derive(Debug, Clone)] pub struct Config { - server_secret_key: Option, + pub server_keypair: KeyPair, } impl Config { pub fn load() -> Result { let mut path = env::current_dir()?; path.push("secrets"); path.push("secret_key"); path.set_extension("txt"); - let key = get_key_from_file(path)?; + let keypair = get_keypair_from_file(path)?; Ok(Self { - server_secret_key: Some(key), + server_keypair: keypair, }) } } #[derive( Debug, derive_more::Display, derive_more::From, derive_more::Error, )] pub enum Error { #[display(...)] Pake(PakeError), #[display(...)] IO(io::Error), } -fn get_key_from_file>(path: P) -> Result { +fn get_keypair_from_file>( + path: P, +) -> Result, Error> { let bytes = fs::read(path)?; - Key::from_bytes(&bytes).map_err(Error::Pake) + KeyPair::from_private_key_slice(&bytes) + .map_err(|e| Error::Pake(PakeError::CryptoError(e))) }