-
Notifications
You must be signed in to change notification settings - Fork 39
refactor: thiserror enums in keys #349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
distractedm1nd
merged 10 commits into
deltadevsde:main
from
Zombeescott:keys_error_enums
Jun 26, 2025
+281
−112
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5556a64
Signing_keys.rs errors updated
Zombeescott 3b2dcfc
Signatures error enums added
Zombeescott e6aea3a
verifiying_keys.rs error enums created
Zombeescott 8aa6846
cleaned-up and removed anyhow from keys
Zombeescott 49c14a5
Added errors.rs file to keys
Zombeescott d9c350e
CryptoErrors setup and verifying_keys implemented it
Zombeescott 401675d
CryptoError fully immplemented in keys
Zombeescott 9e06ce8
Reorganized CryptoErrors enums to be more accurate
Zombeescott 8f0c531
Fixed key lib
Zombeescott b8fb92c
Fixed signing keys
Zombeescott File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
use thiserror::Error; | ||
|
||
pub type Result<G> = std::result::Result<G, CryptoError>; | ||
|
||
#[derive(Error, Debug, Clone)] | ||
pub enum CryptoError { | ||
#[error("signature error: {0}")] | ||
SignatureError(#[from] SignatureError), | ||
|
||
#[error("keys error: {0}")] | ||
KeysError(#[from] KeysError), | ||
|
||
#[error("verification error: {0}")] | ||
VerificationError(#[from] VerificationError), | ||
} | ||
|
||
#[derive(Error, Clone, Debug)] | ||
pub enum SignatureError { | ||
#[error("No {0} specific signatures implemented")] | ||
UnsupportedFormatError(String), | ||
#[error("Malformed signature")] | ||
MalformedSignError, | ||
#[error("Algorithm Error: {0}")] | ||
AlgorithmError(String), | ||
#[error("Something went wrong: {0}")] | ||
CosmosError(String), | ||
} | ||
|
||
#[derive(Error, Clone, Debug)] | ||
pub enum KeysError { | ||
#[error("Creating PKCS8 DER failed")] | ||
DerCreationError, | ||
#[error("Creating PKCS8 PEM failed")] | ||
PemCreationError, | ||
#[error("Parsing key algorithm from PKCS#8 DER failed")] | ||
ParseError, | ||
distractedm1nd marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
#[error("Invalid PEM label")] | ||
PemLabelError, | ||
#[error("Invalid key bytes for algorithm: {0}")] | ||
InvalidKeyBytes(String), | ||
#[error("Signing operation failed: {0}")] | ||
SigningError(String), | ||
} | ||
|
||
#[derive(Error, Clone, Debug)] | ||
pub enum VerificationError { | ||
#[error("Invalid signature type")] | ||
InvalidSignError, | ||
#[error("Failed to verify {0} signature: {1}")] | ||
VerifyError(String, String), | ||
#[error("Verifying key for {0} can only verify secp256k1 signatures")] | ||
SignatureError(String), | ||
#[error("Creating {0} failed")] | ||
CreationError(String), | ||
distractedm1nd marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
#[error("{0} vk from DER format failed: {1}")] | ||
IntoRefError(String, String), | ||
#[error("{0} vk {1} DER format is not implemented")] | ||
NotImplementedError(String, String), | ||
#[error("Something went wrong: {0}")] | ||
GeneralError(String), | ||
} | ||
distractedm1nd marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.