oasis_contract_sdk_types/
crypto.rs

1//! Cryptography-related types.
2use std::convert::TryFrom;
3
4/// Signature kind.
5#[derive(Clone, Copy)]
6#[repr(u32)]
7pub enum SignatureKind {
8    Ed25519 = 0,
9    Secp256k1 = 1,
10    Sr25519 = 2,
11}
12
13impl TryFrom<u32> for SignatureKind {
14    type Error = u32;
15
16    fn try_from(value: u32) -> Result<Self, Self::Error> {
17        match value {
18            0 => Ok(Self::Ed25519),
19            1 => Ok(Self::Secp256k1),
20            2 => Ok(Self::Sr25519),
21            _ => Err(value),
22        }
23    }
24}