1use thiserror::Error;
6
7use super::*;
8use crate::{
9 binary_tree::MlsBinaryTreeDiffError, ciphersuite::signable::SignatureError, error::LibraryError,
10};
11
12#[derive(Error, Debug, PartialEq, Eq, Clone)]
16pub enum PublicTreeError {
17 #[error(transparent)]
19 LibraryError(#[from] LibraryError),
20 #[error("The derived public key doesn't match the one in the tree.")]
22 PublicKeyMismatch,
23 #[error("Found two KeyPackages with the same public key.")]
25 DuplicateKeyPackage,
26 #[error("Couldn't find our own key package in this tree.")]
28 MissingKeyPackage,
29 #[error("The tree is malformed.")]
31 MalformedTree,
32 #[error("A parent hash was invalid.")]
34 InvalidParentHash,
35 #[error("An update failed because the provided credential has a different identity than the one in the leaf node.")]
37 IdentityMismatch,
38 #[error(transparent)]
40 SignatureError(#[from] SignatureError),
41}
42
43#[derive(Error, Debug, PartialEq, Clone)]
45pub enum ApplyUpdatePathError {
46 #[error(transparent)]
48 LibraryError(#[from] LibraryError),
49 #[error(
51 "The length of the received update path and that of the sender's direct path do not match."
52 )]
53 PathLengthMismatch,
54 #[error("The received update path and the derived nodes are not identical.")]
56 PathMismatch,
57 #[error("The parent hash of the ney key package is invalid.")]
59 ParentHashMismatch,
60 #[error("The parent hash of the ney key package is missing.")]
62 MissingParentHash,
63 #[error("Unable to decrypt the path node.")]
65 UnableToDecrypt,
66 #[error("Unable to find sender in tree.")]
68 MissingSender,
69 #[error("Tree is already at maximum size.")]
71 TreeFull,
72 #[error("External Committer used the wrong index.")]
74 InconsistentSenderIndex,
75 #[error("The own leaf is not in the tree.")]
77 MissingOwnLeaf,
78 #[error("The ciphertext is missing in the update path node.")]
80 MissingCiphertext,
81}
82
83#[allow(dead_code)]
87#[derive(Error, Debug, PartialEq, Clone)]
89pub(crate) enum TreeSyncError {
90 #[error(transparent)]
92 LibraryError(#[from] LibraryError),
93 #[error("The leaf does not exist in the tree.")]
95 LeafNotInTree,
96 #[error(transparent)]
98 SetPathError(#[from] DerivePathError),
99 #[error(transparent)]
101 BinaryTreeError(#[from] MlsBinaryTreeError),
102 #[error(transparent)]
104 TreeSyncDiffError(#[from] TreeSyncDiffError),
105 #[error(transparent)]
107 DerivationError(#[from] PathSecretError),
108
109 #[error(transparent)]
111 CryptoError(#[from] CryptoError),
112 #[error("An extension type is not supported by a leaf in the tree.")]
114 UnsupportedExtension,
115 #[error("A capability is not supported by a leaf in the tree.")]
117 UnsupportedCapabilities,
118 #[error("A proposal is not supported by a leaf in the tree.")]
120 UnsupportedProposal,
121}
122
123#[derive(Error, Debug, PartialEq, Clone)]
125pub(crate) enum DerivePathError {
126 #[error(transparent)]
128 LibraryError(#[from] LibraryError),
129 #[error("The derived public key doesn't match the one in the tree.")]
131 PublicKeyMismatch,
132}
133
134#[derive(Error, Debug, PartialEq, Clone)]
136pub enum TreeSyncAddLeaf {
137 #[error(transparent)]
139 LibraryError(#[from] LibraryError),
140 #[error("The tree is full, we cannot add any more leaves.")]
142 TreeFull,
143}
144
145#[derive(Error, Debug, PartialEq, Clone)]
147pub enum TreeSyncFromNodesError {
148 #[error(transparent)]
150 LibraryError(#[from] LibraryError),
151 #[error(transparent)]
153 PublicTreeError(#[from] PublicTreeError),
154 #[error(transparent)]
156 RatchetTreeError(#[from] RatchetTreeError),
157}
158
159#[derive(Error, Debug, PartialEq, Clone)]
161pub(crate) enum TreeSyncParentHashError {
162 #[error(transparent)]
164 LibraryError(#[from] LibraryError),
165 #[error("Parent hash mismatch.")]
167 InvalidParentHash,
168}
169
170#[derive(Error, Debug, PartialEq, Clone)]
172pub(crate) enum TreeSyncDiffError {
173 #[error(transparent)]
175 LibraryError(#[from] LibraryError),
176 #[error(
177 "Couldn't find a fitting private key in the filtered resolution of the given leaf index."
178 )]
179 NoPrivateKeyFound,
180 #[error(transparent)]
182 TreeDiffError(#[from] MlsBinaryTreeDiffError),
183 #[error(transparent)]
185 DerivationError(#[from] PathSecretError),
186 #[error(transparent)]
188 CreationError(#[from] MlsBinaryTreeError),
189}
190
191#[derive(Clone, Debug, Error, Eq, PartialEq)]
193pub enum LeafNodeValidationError {
194 #[error("Lifetime is not acceptable.")]
196 Lifetime(LifetimeError),
197 #[error("Extensions are not acceptable.")]
199 UnsupportedExtensions,
200 #[error("Proposals are not acceptable.")]
202 UnsupportedProposals,
203 #[error("Credentials are not acceptable.")]
205 UnsupportedCredentials,
206 #[error("The leaf node's credential type is not listed in the leaf node's capabilities.")]
208 CredentialNotInCapabilities,
209 #[error(
211 "The leaf node's extension types are not (all) listed in the leaf node's capabilities."
212 )]
213 ExtensionsNotInCapabilities,
214 #[error("The group's ciphersuite is not listed in the leaf node's capabilities.")]
216 CiphersuiteNotInCapabilities,
217 #[error("The leaf node's signature key is already used in the group.")]
219 SignatureKeyAlreadyInUse,
220 #[error("The leaf node's encryption key is already used in the group.")]
222 EncryptionKeyAlreadyInUse,
223 #[error("The leaf node source is invalid in the given context.")]
225 InvalidLeafNodeSource,
226 #[error("The leaf node credential is not supported by all members in the group.")]
228 LeafNodeCredentialNotSupportedByMember,
229 #[error("The credential used by a member is not supported by this leaf node.")]
231 MemberCredentialNotSupportedByLeafNode,
232}
233
234#[derive(Clone, Debug, Error, Eq, PartialEq)]
236pub enum LifetimeError {
237 #[error("Lifetime range is too wide.")]
239 RangeTooBig,
240 #[error("Lifetime doesn't cover current time.")]
242 NotCurrent,
243}
244
245#[derive(Debug, Clone, PartialEq, Eq, Error)]
247pub enum UpdatePathError {
248 #[error("The update path contains an invalid type of leaf node.")]
250 InvalidType,
251 #[error(transparent)]
253 SignatureError(#[from] SignatureError),
254}