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