diff --git a/util/signing/Cargo.toml b/util/signing/Cargo.toml index 14b238e81..208e1c4cb 100644 --- a/util/signing/Cargo.toml +++ b/util/signing/Cargo.toml @@ -10,6 +10,7 @@ publish.workspace = true rust-version.workspace = true [dependencies] +thiserror.workspace = true [lints] workspace = true diff --git a/util/signing/src/lib.rs b/util/signing/src/lib.rs index 70aebc45e..a7b898265 100644 --- a/util/signing/src/lib.rs +++ b/util/signing/src/lib.rs @@ -19,11 +19,26 @@ pub struct KeyVersion(pub String); #[derive(Debug, Clone)] pub struct KeyId(pub String); +/// Errors thrown by SigningService. +#[derive(Debug, thiserror::Error)] +pub enum SignerError { + #[error("Error during signing : {0}")] + Sign(String), + #[error("Error during public key retrieval : {0}")] + GetPublicKey(String), + #[error("Error can't decode provided hex data : {0}")] + Hex(String), + #[error("Signature not found.")] + SignatureNotFound, + #[error("public key not found.")] + PublicKeyNotFound, +} + pub struct SigningService; impl SigningService { /// Create the service with environment variable. - pub fn try_from_env() -> Result { + pub fn try_from_env() -> Result { todo!() } @@ -33,7 +48,7 @@ impl SigningService { &self, message: Bytes, key: KeyId, - ) -> Result<(KeyVersion, Signature), anyhow::Error> { + ) -> Result<(KeyVersion, Signature), SignerError> { todo!(); } @@ -42,7 +57,7 @@ impl SigningService { &self, key: KeyId, version: KeyVersion, - ) -> Result { + ) -> Result { todo!(); } }