ark_mpc/
error.rs

1//! Errors defined across the MPC implementation
2use std::{error::Error, fmt::Display};
3
4use quinn::{ConnectError, ConnectionError};
5
6/// An application level error that results from an error deeper in the MPC
7/// stack
8#[derive(Clone, Debug, PartialEq, Eq)]
9pub enum MpcError {
10    /// An error on the network
11    NetworkError(MpcNetworkError),
12    /// An error authenticating an MPC value
13    AuthenticationError,
14    /// An error resulting from visibility mismatch between two values
15    VisibilityError(String),
16    /// An error performing an arithmetic operation
17    ArithmeticError(String),
18}
19
20impl Display for MpcError {
21    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22        write!(f, "{:?}", self)
23    }
24}
25impl Error for MpcError {}
26
27/// An error on the MPC network during communication
28#[derive(Clone, Debug, PartialEq, Eq)]
29pub enum MpcNetworkError {
30    /// An error sending a value to the counterparty
31    SendError(String),
32    /// An error receiving a value from the counterparty
33    RecvError(String),
34    /// An error setting up the underlying connection
35    ConnectionSetupError(SetupError),
36    /// An error tearing down the underlying connection
37    ConnectionTeardownError,
38    /// An error emitted when a network operation is performed on a network
39    /// that has not yet been `connect`ed
40    NetworkUninitialized,
41    /// An error serializing a value
42    SerializationError(String),
43}
44
45impl Display for MpcNetworkError {
46    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
47        write!(f, "{:?}", self)
48    }
49}
50impl Error for MpcNetworkError {}
51
52/// An error setting up the MPC fabric
53#[derive(Clone, Debug, PartialEq, Eq)]
54pub enum SetupError {
55    /// An error connecting to the peer
56    ConnectError(ConnectError),
57    /// An error with the connection after initial setup
58    ConnectionError(ConnectionError),
59    /// An error setting up the TLS certificate
60    KeygenError,
61    /// An error emitted when there is no inbound connection attempt from the
62    /// suggested peer
63    NoIncomingConnection,
64    /// An error setting up the QUIC server on the local node
65    ServerSetupError,
66}