use crate::{
client::{self, ErrorKind::ResponseError},
command::{self, Command},
object,
response::Response,
};
use serde::{Deserialize, Serialize};
use signatory::Signature;
#[derive(Serialize, Deserialize, Debug)]
pub(crate) struct SignEddsaCommand {
pub key_id: object::Id,
pub data: Vec<u8>,
}
impl Command for SignEddsaCommand {
type ResponseType = SignEddsaResponse;
}
#[derive(Serialize, Deserialize, Debug)]
pub struct SignEddsaResponse(pub(crate) Vec<u8>);
impl Response for SignEddsaResponse {
const COMMAND_CODE: command::Code = command::Code::SignEddsa;
}
impl SignEddsaResponse {
pub(crate) fn signature(&self) -> Result<super::Signature, client::Error> {
super::Signature::from_bytes(&self.0).map_err(|e| err!(ResponseError, e))
}
}