diff --git a/services/identity/src/config.rs b/services/identity/src/config.rs --- a/services/identity/src/config.rs +++ b/services/identity/src/config.rs @@ -1,9 +1,10 @@ -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 { @@ -12,9 +13,9 @@ 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, }) } } @@ -29,7 +30,10 @@ 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))) }