pub struct KeysService {
pub kms_client_service: Arc<dyn KmsClientService>,
pub crypto_service: CryptoService,
}Fields§
§kms_client_service: Arc<dyn KmsClientService>§crypto_service: CryptoServiceImplementations§
Source§impl KeysService
impl KeysService
Sourcepub async fn new(
config: Config,
crypto_service: CryptoService,
) -> Result<Self, String>
pub async fn new( config: Config, crypto_service: CryptoService, ) -> Result<Self, String>
Creates a new KeyService instance with the given config and crypto service.
Initializes the appropriate KMS client (AWS or else) based on the config.
§Errors
Returns an error if the AWS KMS client fails to initialize.
Sourcepub async fn sign(
&mut self,
transaction_hash_hex: &str,
key: &str,
prefix: Option<&str>,
) -> Result<String, String>
pub async fn sign( &mut self, transaction_hash_hex: &str, key: &str, prefix: Option<&str>, ) -> Result<String, String>
Signs a given transaction hash using the specified key.
This function delegates signing to the underlying KMS client service, then converts the resulting signature into the expected format. An optional prefix can be prepended to the final signature string.
§Parameters
transaction_hash_hex: The transaction hash to sign, as a hex-encoded string.key: The key or alias to use for signing.prefix: An optional string slice to prepend to the signature (e.g., a format or type prefix).
§Returns
Ok(String): The formatted signature string, optionally prefixed.Err(String): An error message if signing or signature conversion fails.
§Errors
Returns an error if:
- The KMS client service fails to produce a signature for the given hash and key.
- Conversion of the raw signature bytes into the desired format fails.
Sourcepub fn verify(
&mut self,
transaction_hash_hex: &str,
signature_hex: &str,
public_key: &str,
) -> Result<bool, String>
pub fn verify( &mut self, transaction_hash_hex: &str, signature_hex: &str, public_key: &str, ) -> Result<bool, String>
Verifies a signature against a transaction hash and public key.
§Arguments
transaction_hash_hex- The hex-encoded transaction hash to verify.signature_hex- The hex-encoded signature to verify.public_key- The public key to use for verification.
§Errors
Returns an error string if the verification process fails.
§Returns
Ok(true) if the signature is valid, Ok(false) if invalid.
Sourcepub fn verify_eip155(
&mut self,
transaction_hash_hex: &str,
signature_hex: &str,
public_key: &str,
) -> Result<bool, String>
pub fn verify_eip155( &mut self, transaction_hash_hex: &str, signature_hex: &str, public_key: &str, ) -> Result<bool, String>
Verifies an Ethereum EIP-155 signature against a transaction hash and public key.
§Arguments
transaction_hash_hex- The hex-encoded transaction hash to verify.signature_hex- The hex-encoded signature to verify.public_key- The public key to use for verification.
§Errors
Returns an error string if the verification process fails.
§Returns
Ok(true) if the signature is valid, Ok(false) if invalid.
Sourcepub async fn verify_via_kms(
&mut self,
transaction_hash_hex: &str,
signature_hex: &str,
public_key: &str,
) -> Result<bool, String>
pub async fn verify_via_kms( &mut self, transaction_hash_hex: &str, signature_hex: &str, public_key: &str, ) -> Result<bool, String>
Verifies a signature against a transaction hash and public key using both local crypto verification and KMS verification.
First, verifies the signature locally via the crypto service. If that succeeds, converts the signature to ASN.1 base64 format and verifies it via the KMS client.
§Arguments
transaction_hash_hex- Hex-encoded transaction hash to verify.signature_hex- Hex-encoded signature to verify.public_key- Public key used for verification.
§Errors
Returns an error string if either local or KMS verification fails.
§Returns
Ok(true) if both verifications pass, Ok(false) if local verification fails.
Sourcepub async fn verify_via_kms_eip155(
&mut self,
transaction_hash_hex: &str,
signature_hex: &str,
public_key: &str,
) -> Result<bool, String>
pub async fn verify_via_kms_eip155( &mut self, transaction_hash_hex: &str, signature_hex: &str, public_key: &str, ) -> Result<bool, String>
Verifies an EIP-155 signature and then confirms it via KMS.
This method first performs a cryptographic verification of the signature according to EIP-155. If that succeeds, it proceeds to verify the signature via the KMS service.
§Parameters
transaction_hash_hex: The transaction hash to verify, as a hex-encoded string.signature_hex: The signature to verify, as a hex-encoded string.public_key: The public key corresponding to the signer, as a hex string.
§Returns
Ok(true)if both cryptographic and KMS verifications succeed.Ok(false)if the cryptographic verification fails.Err(String)if any error occurs during verification.
§Errors
Returns an error if:
- The inputs cannot be parsed or decoded correctly.
- The cryptographic verification process encounters an unexpected error.
- The KMS verification call fails or returns an error.
Auto Trait Implementations§
impl Freeze for KeysService
impl !RefUnwindSafe for KeysService
impl Send for KeysService
impl Sync for KeysService
impl Unpin for KeysService
impl !UnwindSafe for KeysService
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.