-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- [x] modularity - [x] crypto operation is in one mod. algorithm includes ed25519 secp256k1 and more。struct includes secret_key public_key and pair_key. - [x] errors is in one mod,and in the crypto directory。 - [x] crypto mod only handle related operations of sign. no associated with specific chain. - [x] interface adjustment - unify key string format:key_type:encode_type:xxxxxxxxx - [ ] detailed document issue: Problem: ed25519-signing is not supported #415
- Loading branch information
Showing
5 changed files
with
392 additions
and
14 deletions.
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 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 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,32 @@ | ||
use super::KeyType; | ||
use super::EncodeType; | ||
|
||
|
||
/// uniffi don't support Box<dyn std::error::Error> so convert a lower error to a string. discard the source | ||
#[derive(Debug, Clone, thiserror::Error)] | ||
pub enum ParseKeyError { | ||
#[error("key_type: {key_type} {msg}")] | ||
InvalidKeyBytes{key_type: KeyType, msg: String}, | ||
#[error("invalid format, colon_number expected 2 but {colon_number}. the format is key_type:encode_type:xxxxx")] | ||
InvalidStringFormat{colon_number: u8}, | ||
#[error("unknown key type '{unknown_key_type}'")] | ||
UnknownKeyType { unknown_key_type: String }, | ||
#[error("unknown encode type '{unknown_encode_type}'")] | ||
UnknownEncodeType { unknown_encode_type: String }, | ||
#[error("invalid encode format: key_type: {key_type} encode_type: {encode_type} cause: {cause}")] | ||
InvalidEncodeFormat { key_type: KeyType, encode_type: EncodeType, cause: String }, | ||
#[error("invalid key length: expected the input of {expected_length} bytes, but {received_length} was given")] | ||
InvalidLength { expected_length: usize, received_length: usize }, | ||
#[error("invalid key data: {error_message}")] | ||
InvalidData { error_message: String }, | ||
} | ||
|
||
#[derive(Debug, Clone, thiserror::Error)] | ||
pub enum ParseSignatureError { | ||
#[error("unknown key type '{unknown_key_type}'")] | ||
UnknownKeyType { unknown_key_type: String }, | ||
#[error("invalid signature length: expected the input of {expected_length} bytes, but {received_length} was given")] | ||
InvalidLength { expected_length: usize, received_length: usize }, | ||
#[error("invalid signature data: {error_message}")] | ||
InvalidData { error_message: String }, | ||
} |
Oops, something went wrong.