Skip to content

Commit

Permalink
add error to sign API
Browse files Browse the repository at this point in the history
  • Loading branch information
musitdev committed Dec 18, 2024
1 parent 37cfc8e commit 7ba55d9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions util/signing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ publish.workspace = true
rust-version.workspace = true

[dependencies]
thiserror.workspace = true

[lints]
workspace = true
21 changes: 18 additions & 3 deletions util/signing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self, anyhow::Error> {
pub fn try_from_env() -> Result<Self, SignerError> {
todo!()
}

Expand All @@ -33,7 +48,7 @@ impl SigningService {
&self,
message: Bytes,
key: KeyId,
) -> Result<(KeyVersion, Signature), anyhow::Error> {
) -> Result<(KeyVersion, Signature), SignerError> {
todo!();
}

Expand All @@ -42,7 +57,7 @@ impl SigningService {
&self,
key: KeyId,
version: KeyVersion,
) -> Result<PublicKey, anyhow::Error> {
) -> Result<PublicKey, SignerError> {
todo!();
}
}

0 comments on commit 7ba55d9

Please sign in to comment.