1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//! Cryptography-related types.
use std::convert::TryFrom;

/// Signature kind.
#[derive(Clone, Copy)]
#[repr(u32)]
pub enum SignatureKind {
    Ed25519 = 0,
    Secp256k1 = 1,
    Sr25519 = 2,
}

impl TryFrom<u32> for SignatureKind {
    type Error = u32;

    fn try_from(value: u32) -> Result<Self, Self::Error> {
        match value {
            0 => Ok(Self::Ed25519),
            1 => Ok(Self::Secp256k1),
            2 => Ok(Self::Sr25519),
            _ => Err(value),
        }
    }
}