Skip to main content

openmls/group/public_group/
errors.rs

1use openmls_traits::types::Ciphersuite;
2use thiserror::Error;
3
4use crate::{
5    error::LibraryError,
6    extensions::errors::InvalidExtensionError,
7    treesync::{
8        errors::{LeafNodeValidationError, TreeSyncFromNodesError},
9        node::leaf_node::LeafNodeBuildError,
10    },
11};
12
13/// Public group creation from external error.
14#[derive(Error, Debug, PartialEq, Clone)]
15pub enum CreationFromExternalError<StorageError> {
16    /// See [`LibraryError`] for more details.
17    #[error(transparent)]
18    LibraryError(#[from] LibraryError),
19    /// This error indicates the public tree is invalid. See [`TreeSyncFromNodesError`] for more details.
20    #[error(transparent)]
21    TreeSyncError(#[from] TreeSyncFromNodesError),
22    /// Sender not found in tree.
23    #[error("Sender not found in tree.")]
24    UnknownSender,
25    /// The signature on the GroupInfo is not valid.
26    #[error("The signature on the GroupInfo is not valid.")]
27    InvalidGroupInfoSignature,
28    /// The computed tree hash does not match the one in the GroupInfo.
29    #[error("The computed tree hash does not match the one in the GroupInfo.")]
30    TreeHashMismatch,
31    /// We don't support the version of the group we are trying to join.
32    #[error("We don't support the version of the group we are trying to join.")]
33    UnsupportedMlsVersion,
34    /// The ciphersuite is not supported by the crypto provider.
35    #[error("Ciphersuite {0:?} is not supported by the crypto provider.")]
36    UnsupportedCiphersuite(Ciphersuite),
37    /// See [`LeafNodeValidationError`]
38    #[error(transparent)]
39    LeafNodeValidation(#[from] LeafNodeValidationError),
40    /// Error writing to storage.
41    #[error("Error writing to storage: {0}")]
42    WriteToStorageError(StorageError),
43    /// A parent node has an unmerged leaf that is not a descendant of the node.
44    #[error("A parent node has an unmerged leaf that is not a descendant of the node")]
45    UnmergedLeafNotADescendant,
46    /// Found a path from a parent with an unmerged leaf to the leaf with nodes that do not have that as a leaf  
47    #[error("Found a path from a parent with an unmerged leaf to the leaf with nodes that do not have that as a leaf")]
48    IntermediateNodeMissingUnmergedLeaf,
49    /// The ratchet tree contains duplcate encryption keys
50    #[error("The ratchet tree contains duplcate encryption keys")]
51    DuplicateEncryptionKey,
52    /// The ratchet tree contains duplcate signature keys
53    #[error("The ratchet tree contains duplcate signature keys")]
54    DuplicateSignatureKey,
55}
56
57/// Public group builder error.
58#[derive(Error, Debug, PartialEq, Clone)]
59pub enum PublicGroupBuildError {
60    /// See [`LibraryError`] for more details.
61    #[error(transparent)]
62    LibraryError(#[from] LibraryError),
63    /// Invalid extensions set in configuration
64    #[error("Invalid extensions set in configuration")]
65    InvalidExtensions(#[from] InvalidExtensionError),
66    /// The leaf node's capabilities don't cover what the leaf itself uses.
67    #[error(transparent)]
68    LeafNodeBuild(#[from] LeafNodeBuildError),
69}
70
71/// The errors that may occur while applying AppDataUpdate proposals
72#[cfg(feature = "extensions-draft")]
73#[derive(Error, Debug, PartialEq, Clone)]
74pub enum ApplyAppDataUpdateError {
75    /// Found AppDataUpdate proposals, but was not provided the updated values
76    #[error("Found AppDataUpdate proposals, but was not provided the updated values")]
77    MissingAppDataUpdates,
78    /// No AppDataUpdate proposals found, but was provided updated values
79    #[error("No AppDataUpdate proposals found, but was provided updated values")]
80    SuperfluousAppDataUpdates,
81    /// See [`LibraryError`] for more details.
82    #[error(transparent)]
83    LibraryError(#[from] LibraryError),
84}