p2panda_rs/secret_group/
error.rs

1// SPDX-License-Identifier: AGPL-3.0-or-later
2
3//! Error types for creating and managing a secret group.
4use thiserror::Error;
5
6/// Custom error types for `SecretGroup`.
7#[derive(Error, Debug)]
8#[allow(missing_copy_implementations)]
9pub enum SecretGroupError {
10    /// Commit messages and new long-term secrets can only be created by group owners.
11    #[error("this method can only be used by group owners")]
12    NotOwner,
13
14    /// MLS commit message was expected to contain a welcome message as well.
15    #[error("commit does not contain welcome message")]
16    WelcomeMissing,
17
18    /// Long-term secret does not match current secret group.
19    #[error("long-term secret has an invalid group id")]
20    LTSInvalidGroupID,
21
22    /// User data could not be decrypted since long-term secret is missing.
23    #[error("can not decrypt long-term secret since key material is missing")]
24    LTSSecretMissing,
25
26    /// LTS secret encoding failed.
27    #[error("could not encode long-term secret")]
28    LTSEncodingError,
29
30    /// LTS secret decoding failed. Maybe the data was corrupted or invalid?
31    #[error("could not decode long-term secret")]
32    LTSDecodingError,
33
34    /// Member's public key cannot be decoded as an Ed25519 public key.
35    #[error("member's public key is not a valid Ed25519 public key")]
36    InvalidMemberPublicKey,
37
38    /// Decoding failed with unknown value.
39    #[error("unknown value found during decoding")]
40    UnknownValue,
41
42    /// Error coming from `mls` sub-module.
43    #[error(transparent)]
44    MlsError(#[from] crate::secret_group::mls::error::MlsError),
45
46    /// Error coming from `lts` sub-module.
47    #[error(transparent)]
48    LTSError(#[from] crate::secret_group::lts::error::LongTermSecretError),
49}