Trait KeyType

Source
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§

Required Methods§

Source

fn key_type_id() -> KeyTypeId

Source

fn generate_with_seed(seed: Option<&[u8]>) -> Result<Self::Secret, Self::Error>

Source

fn generate_with_string(secret: String) -> Result<Self::Secret, Self::Error>

Source

fn public_from_secret(secret: &Self::Secret) -> Self::Public

Source

fn sign_with_secret( secret: &mut Self::Secret, msg: &[u8], ) -> Result<Self::Signature, Self::Error>

Source

fn sign_with_secret_pre_hashed( secret: &mut Self::Secret, msg: &[u8; 32], ) -> Result<Self::Signature, Self::Error>

Source

fn verify( public: &Self::Public, msg: &[u8], signature: &Self::Signature, ) -> bool

Provided Methods§

Source

fn get_rng() -> impl CryptoRng + Rng

Get a cryptographically secure random number generator

Source

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.

Implementations on Foreign Types§

Source§

impl KeyType for W3fBls377

Source§

impl KeyType for W3fBls381

Source§

impl KeyType for ArkBlsBn254

Source§

impl KeyType for Ed25519Zebra

Source§

impl KeyType for K256Ecdsa

Source§

impl KeyType for SpEcdsa

Source§

impl KeyType for SpEd25519

Source§

impl KeyType for SpSr25519

Source§

impl KeyType for SchnorrkelSr25519

Implementors§