Skip to main content

ic_atp/domain/models/
signer.rs

1use candid::{CandidType, Decode, Encode};
2use ic_stable_structures::{storable::Bound, Storable};
3use serde::{Deserialize, Serialize};
4use std::borrow::Cow;
5
6#[derive(CandidType, Clone, Serialize, Deserialize, Debug, PartialEq)]
7pub enum SignatureAlgorithm {
8    #[serde(rename = "ecdsa")]
9    Ecdsa,
10    #[serde(rename = "schnorr")]
11    Schnorr,
12}
13
14impl Storable for SignatureAlgorithm {
15    fn to_bytes(&self) -> Cow<[u8]> {
16        Cow::Owned(Encode!(self).unwrap())
17    }
18
19    fn from_bytes(bytes: Cow<[u8]>) -> Self {
20        Decode!(bytes.as_ref(), SignatureAlgorithm).unwrap()
21    }
22
23    const BOUND: Bound = Bound::Unbounded;
24}