pub trait KeyType:
Sized
+ Clone
+ Eq
+ Debug
+ PartialEq
+ Ord
+ PartialOrd
+ Hash
+ Send
+ Sync
+ Serialize
+ DeserializeOwned
+ 'static {
type Secret: Clone + Serialize + DeserializeOwned + Ord + Send + Sync + Eq + PartialEq + BytesEncoding + Debug;
type Public: Clone + Serialize + DeserializeOwned + Ord + Send + Sync + Hash + Eq + PartialEq + BytesEncoding + Debug;
type Signature: Clone + Serialize + DeserializeOwned + Ord + Send + Sync + Eq + PartialEq + BytesEncoding + Debug;
type Error: Clone + Send + Sync + Debug;
// Required methods
fn key_type_id() -> KeyTypeId;
fn generate_with_seed(
seed: Option<&[u8]>,
) -> Result<Self::Secret, Self::Error>;
fn generate_with_string(secret: String) -> Result<Self::Secret, Self::Error>;
fn public_from_secret(secret: &Self::Secret) -> Self::Public;
fn sign_with_secret(
secret: &mut Self::Secret,
msg: &[u8],
) -> Result<Self::Signature, Self::Error>;
fn sign_with_secret_pre_hashed(
secret: &mut Self::Secret,
msg: &[u8; 32],
) -> Result<Self::Signature, Self::Error>;
fn verify(
public: &Self::Public,
msg: &[u8],
signature: &Self::Signature,
) -> bool;
// Provided methods
fn get_rng() -> impl CryptoRng + Rng { ... }
fn get_test_rng() -> impl CryptoRng + Rng { ... }
}
Expand description
Trait for key types that can be stored in the keystore
Required Associated Types§
type Secret: Clone + Serialize + DeserializeOwned + Ord + Send + Sync + Eq + PartialEq + BytesEncoding + Debug
type Public: Clone + Serialize + DeserializeOwned + Ord + Send + Sync + Hash + Eq + PartialEq + BytesEncoding + Debug
type Signature: Clone + Serialize + DeserializeOwned + Ord + Send + Sync + Eq + PartialEq + BytesEncoding + Debug
type Error: Clone + Send + Sync + Debug
Required Methods§
fn key_type_id() -> KeyTypeId
fn generate_with_seed(seed: Option<&[u8]>) -> Result<Self::Secret, Self::Error>
fn generate_with_string(secret: String) -> Result<Self::Secret, Self::Error>
fn public_from_secret(secret: &Self::Secret) -> Self::Public
fn sign_with_secret( secret: &mut Self::Secret, msg: &[u8], ) -> Result<Self::Signature, Self::Error>
fn sign_with_secret_pre_hashed( secret: &mut Self::Secret, msg: &[u8; 32], ) -> Result<Self::Signature, Self::Error>
fn verify( public: &Self::Public, msg: &[u8], signature: &Self::Signature, ) -> bool
Provided Methods§
Sourcefn get_test_rng() -> impl CryptoRng + Rng
fn get_test_rng() -> impl CryptoRng + Rng
Get a deterministic random number generator for testing
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.