use super::Signature;
use crate::{
client::{self, ErrorKind::ResponseError},
command::{self, Command},
object,
response::Response,
};
use serde::{Deserialize, Serialize};
use signature::Signature as _;
#[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<Signature, client::Error> {
Signature::from_bytes(&self.0).map_err(|e| ResponseError.context(e).into())
}
}