flamingo_verifier_client/error.rs
1//! The crate's error type.
2
3use pontifex::{ChannelError, attestation};
4
5/// Failures while configuring or calling the host.
6#[derive(Debug, thiserror::Error)]
7pub enum Error {
8 /// A configuration field was not usable.
9 #[error("invalid {attribute}: {reason}")]
10 InvalidConfig {
11 /// Which field.
12 attribute: String,
13 /// Why it was rejected.
14 reason: String,
15 },
16
17 /// The configuration JSON could not be parsed.
18 #[error("failed to parse config: {0}")]
19 MalformedConfig(String),
20
21 /// An attestation document did not verify.
22 #[error(transparent)]
23 Attestation(#[from] attestation::Error),
24
25 /// The assignment document or public key was not valid base64.
26 #[error("assignment document or public key was not valid base64")]
27 MalformedAssignment,
28
29 /// The assignment is stale: re-assign, re-seal, and retry once.
30 #[error("the request was not sealed to the enclave's current key; re-assign and retry once")]
31 ReassignRequired,
32
33 /// Channel attestation, key binding, sealing or opening failed.
34 #[error("sealed channel failure: {0:?}")]
35 Channel(#[source] ChannelError),
36
37 /// The request violated a WIP-201 bound or its AAT did not verify.
38 #[error("match request was malformed")]
39 MalformedRequest,
40 /// The attested release does not define the request's pipeline or `match_strictness`, or the
41 /// request's `pipeline_inputs` do not fit the pipeline.
42 #[error("the enclave's release does not support the request's pipeline or strictness")]
43 ReleaseUnavailable,
44 /// The request's pipeline lists more response slots than the configured maximum, so its
45 /// response timing could reveal too much (WIP-201 ยง4.6 step 3).
46 #[error("the pipeline lists more response slots than the configured maximum")]
47 TooManyResponseSlots,
48 /// The assignment's attestation does not carry the `release_hash` of its release manifest.
49 #[error("the attestation does not attest the assignment's release manifest")]
50 ReleaseNotAttested,
51 /// The sealed plaintext was not a match result.
52 #[error("sealed response was not a match result")]
53 MalformedResult,
54
55 /// The attested signing public key was not a valid `BabyJubJub` point.
56 #[error("attested signing public key was invalid")]
57 InvalidSigningKey,
58
59 /// The statement did not verify under the attested signing key.
60 #[error("match statement did not verify under the attested signing key")]
61 StatementInvalid,
62
63 /// The WebSocket handshake or an I/O operation on it failed.
64 #[error("WebSocket transport failed: {0}")]
65 WebSocket(#[source] tokio_tungstenite::tungstenite::Error),
66
67 /// An operation did not finish within its configured deadline.
68 #[error("the host did not respond within the configured deadline")]
69 Timeout,
70
71 /// The host closed the WebSocket before the exchange completed.
72 #[error("the host closed the connection before the exchange completed")]
73 ConnectionClosed,
74
75 /// A frame was not the message the protocol expects at that point.
76 #[error("the host sent an unexpected or malformed message")]
77 MalformedMessage,
78
79 /// The host returned an error envelope over the WebSocket.
80 #[error("host returned error ({code})")]
81 ApiFrame {
82 /// Machine-readable code from the envelope.
83 code: String,
84 /// Whether the host says the request may be retried.
85 allow_retry: bool,
86 },
87}