polysig_driver/cggmp/
error.rsuse k256::ecdsa::VerifyingKey;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error("{0}")]
LocalError(String),
#[error("{0}")]
RemoteError(String),
#[error("failed to verify generated signature")]
VerifySignature,
#[error("could not find an ACK for key init phase")]
NoKeyInitAck,
#[error("protocol is not finished, another round is available")]
NotFinished,
#[error(transparent)]
Protocol(#[from] polysig_protocol::Error),
#[error(transparent)]
FromInt(#[from] std::num::TryFromIntError),
#[error(transparent)]
Bip32(#[from] synedrion::bip32::Error),
}
impl From<synedrion::sessions::LocalError> for Error {
fn from(value: synedrion::sessions::LocalError) -> Self {
Error::LocalError(value.to_string())
}
}
impl From<synedrion::sessions::RemoteError<VerifyingKey>> for Error {
fn from(
value: synedrion::sessions::RemoteError<VerifyingKey>,
) -> Self {
Error::RemoteError(format!("{:#?}", value.error))
}
}
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
impl From<Error> for wasm_bindgen::JsValue {
fn from(value: Error) -> Self {
let s = value.to_string();
wasm_bindgen::JsValue::from_str(&s)
}
}