use core::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum OsstError {
EmptyContributions,
InsufficientContributions { got: usize, need: usize },
DuplicateIndex(u32),
ZeroChallenge,
InvalidCommitment,
InvalidResponse,
LagrangeError,
InvalidIndex,
}
impl fmt::Display for OsstError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::EmptyContributions => write!(f, "no contributions provided"),
Self::InsufficientContributions { got, need } => {
write!(f, "insufficient contributions: got {}, need {}", got, need)
}
Self::DuplicateIndex(idx) => write!(f, "duplicate custodian index: {}", idx),
Self::ZeroChallenge => write!(f, "challenge hash is zero"),
Self::InvalidCommitment => write!(f, "invalid commitment point"),
Self::InvalidResponse => write!(f, "invalid response scalar"),
Self::LagrangeError => write!(f, "lagrange coefficient computation failed"),
Self::InvalidIndex => write!(f, "index must be greater than 0"),
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for OsstError {}