1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
use openmls_traits::{crypto::OpenMlsCrypto, types::CryptoError, OpenMlsCryptoProvider};
use serde::{Deserialize, Serialize};
use std::{collections::HashSet, convert::TryFrom};
use super::{
node::{
leaf_node::LeafNode,
parent_node::{ParentNode, ParentNodeError, PathDerivationResult, PlainUpdatePathNode},
{Node, NodeError},
},
treesync_node::{TreeSyncNode, TreeSyncNodeError},
TreeSync,
};
use crate::{
binary_tree::{
array_representation::diff::NodeId, LeafIndex, MlsBinaryTreeDiff, MlsBinaryTreeDiffError,
MlsBinaryTreeError, StagedMlsBinaryTreeDiff,
},
ciphersuite::{
hash_ref::KeyPackageRef, signable::Signable, Ciphersuite, HpkePrivateKey, HpkePublicKey,
Secret,
},
credentials::CredentialBundle,
error::LibraryError,
extensions::ExtensionType,
key_packages::{KeyPackage, KeyPackageBundlePayload, KeyPackageError},
messages::{PathSecret, PathSecretError},
schedule::CommitSecret,
};
pub(crate) type UpdatePathResult = (KeyPackage, Vec<PlainUpdatePathNode>, CommitSecret);
#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct StagedTreeSyncDiff {
own_leaf_index: LeafIndex,
diff: StagedMlsBinaryTreeDiff<TreeSyncNode>,
new_tree_hash: Vec<u8>,
}
impl StagedTreeSyncDiff {
pub(super) fn into_parts(self) -> (LeafIndex, StagedMlsBinaryTreeDiff<TreeSyncNode>, Vec<u8>) {
(self.own_leaf_index, self.diff, self.new_tree_hash)
}
}
pub(crate) struct TreeSyncDiff<'a> {
diff: MlsBinaryTreeDiff<'a, TreeSyncNode>,
own_leaf_index: LeafIndex,
}
impl<'a> TryFrom<&'a TreeSync> for TreeSyncDiff<'a> {
type Error = TreeSyncDiffError;
fn try_from(tree_sync: &'a TreeSync) -> Result<Self, Self::Error> {
Ok(TreeSyncDiff {
diff: tree_sync.tree.empty_diff()?,
own_leaf_index: tree_sync.own_leaf_index,
})
}
}
impl<'a> TreeSyncDiff<'a> {
pub(crate) fn trim_tree(&mut self) -> Result<(), TreeSyncDiffError> {
if self.leaf_count() == 1 {
return Ok(());
}
let mut leaf_id = self.diff.leaf(self.leaf_count() - 1)?;
let mut parent_id = self.diff.parent(leaf_id)?;
while self.diff.node(leaf_id)?.node().is_none()
&& self.diff.node(parent_id)?.node().is_none()
{
self.diff.remove_leaf()?;
if self.leaf_count() == 1 {
return Ok(());
}
leaf_id = self.diff.leaf(self.leaf_count() - 1)?;
parent_id = self.diff.parent(leaf_id)?;
}
Ok(())
}
pub(crate) fn leaf_count(&self) -> LeafIndex {
self.diff.leaf_count()
}
pub(crate) fn update_leaf(
&mut self,
leaf_node: impl Into<LeafNode>,
leaf_index: LeafIndex,
) -> Result<(), TreeSyncDiffError> {
let node = Node::LeafNode(leaf_node.into());
self.diff.replace_leaf(leaf_index, node.into())?;
self.diff
.set_direct_path_to_node(leaf_index, &TreeSyncNode::blank())?;
Ok(())
}
pub(crate) fn free_leaf_index(&self) -> Result<LeafIndex, TreeSyncDiffError> {
let leaf_ids = self.diff.leaves()?;
let mut leaf_index_option = None;
for (leaf_index, leaf_id) in leaf_ids.iter().enumerate() {
let leaf_index: LeafIndex = u32::try_from(leaf_index)
.map_err(|_| LibraryError::custom("free_leaf_index(): Could not convert index"))?;
if self.diff.node(*leaf_id)?.node().is_none() {
leaf_index_option = Some(leaf_index);
break;
}
}
Ok(leaf_index_option.unwrap_or_else(|| self.leaf_count()))
}
pub(crate) fn add_leaf(
&mut self,
leaf_node: KeyPackage,
backend: &impl OpenMlsCrypto,
) -> Result<LeafIndex, TreeSyncDiffError> {
let node = Node::LeafNode(LeafNode::new(leaf_node, backend).map_err(|e| {
if let KeyPackageError::CryptoError(e) = e {
TreeSyncDiffError::CryptoError(e)
} else {
TreeSyncDiffError::LibraryError(LibraryError::custom(
"TreeSyncDiff::add_leaf(): key package error",
))
}
})?);
let leaf_index = self.free_leaf_index()?;
if leaf_index < self.leaf_count() {
self.diff.replace_leaf(leaf_index, node.into())?;
} else {
self.diff.add_leaf(TreeSyncNode::blank(), node.into())?;
}
for node_id in self.diff.direct_path(leaf_index)? {
let tsn = self.diff.node_mut(node_id)?;
if let Some(ref mut node) = tsn.node_mut() {
let pn = node.as_parent_node_mut()?;
pn.add_unmerged_leaf(leaf_index);
}
tsn.erase_tree_hash();
}
Ok(leaf_index)
}
pub(crate) fn set_own_index(&mut self, leaf_index: LeafIndex) {
self.own_leaf_index = leaf_index
}
pub(crate) fn blank_leaf(&mut self, leaf_index: LeafIndex) -> Result<(), TreeSyncDiffError> {
self.diff.replace_leaf(leaf_index, TreeSyncNode::blank())?;
self.diff
.set_direct_path_to_node(leaf_index, &TreeSyncNode::blank())?;
self.trim_tree()?;
Ok(())
}
fn derive_path_from_leaf_secret(
&self,
backend: &impl OpenMlsCryptoProvider,
ciphersuite: &Ciphersuite,
leaf_secret: Secret,
) -> Result<PathDerivationResult, TreeSyncDiffError> {
let leaf_path_secret = PathSecret::from(leaf_secret);
let path_secret = leaf_path_secret.derive_path_secret(backend, ciphersuite)?;
let path_length = self.diff.direct_path(self.own_leaf_index)?.len();
Ok(ParentNode::derive_path(
backend,
ciphersuite,
path_secret,
path_length,
)?)
}
pub(crate) fn apply_own_update_path(
&mut self,
backend: &impl OpenMlsCryptoProvider,
ciphersuite: &Ciphersuite,
mut key_package_bundle_payload: KeyPackageBundlePayload,
credential_bundle: &CredentialBundle,
) -> Result<UpdatePathResult, TreeSyncDiffError> {
let leaf_secret = key_package_bundle_payload.leaf_secret().clone();
let (path, update_path_nodes, commit_secret) =
self.derive_path_from_leaf_secret(backend, ciphersuite, leaf_secret)?;
let parent_hash =
self.process_update_path(backend, ciphersuite, self.own_leaf_index, path)?;
key_package_bundle_payload.update_parent_hash(&parent_hash);
let key_package_bundle = key_package_bundle_payload.sign(backend, credential_bundle)?;
let key_package = key_package_bundle.key_package().clone();
let node = Node::LeafNode(LeafNode::new_from_bundle(
key_package_bundle,
backend.crypto(),
)?);
self.diff.replace_leaf(self.own_leaf_index, node.into())?;
Ok((key_package, update_path_nodes, commit_secret))
}
pub(crate) fn apply_received_update_path(
&mut self,
backend: &impl OpenMlsCryptoProvider,
ciphersuite: &Ciphersuite,
sender_leaf_index: LeafIndex,
key_package: KeyPackage,
path: Vec<ParentNode>,
) -> Result<(), TreeSyncDiffError> {
let parent_hash =
self.process_update_path(backend, ciphersuite, sender_leaf_index, path)?;
let phe = key_package
.extension_with_type(ExtensionType::ParentHash)
.ok_or(TreeSyncDiffError::MissingParentHash)?;
let key_package_parent_hash = phe
.as_parent_hash_extension()
.map_err(|_| {
LibraryError::custom("apply_received_update-path(): No parent hash etxension")
})?
.parent_hash();
if key_package_parent_hash != parent_hash {
return Err(TreeSyncDiffError::ParentHashMismatch);
};
let node = Node::LeafNode(LeafNode::new(key_package, backend.crypto()).map_err(|e| {
if let KeyPackageError::CryptoError(e) = e {
TreeSyncDiffError::CryptoError(e)
} else {
TreeSyncDiffError::LibraryError(LibraryError::custom(
"TreeSynDiff::apply_received_update_path(): key package error",
))
}
})?);
self.diff.replace_leaf(sender_leaf_index, node.into())?;
Ok(())
}
fn process_update_path(
&mut self,
backend: &impl OpenMlsCryptoProvider,
ciphersuite: &Ciphersuite,
leaf_index: LeafIndex,
mut path: Vec<ParentNode>,
) -> Result<Vec<u8>, TreeSyncDiffError> {
let parent_hash = self.set_parent_hashes(backend, ciphersuite, &mut path, leaf_index)?;
let direct_path: Vec<TreeSyncNode> = path
.into_iter()
.map(|parent_node| Node::ParentNode(parent_node).into())
.collect();
self.diff.set_direct_path(leaf_index, direct_path)?;
Ok(parent_hash)
}
pub(super) fn set_path_secrets(
&mut self,
backend: &impl OpenMlsCryptoProvider,
ciphersuite: &Ciphersuite,
mut path_secret: PathSecret,
sender_index: LeafIndex,
) -> Result<CommitSecret, TreeSyncDiffError> {
let subtree_path = self.diff.subtree_path(self.own_leaf_index, sender_index)?;
for node_id in subtree_path {
let tsn = self.diff.node_mut(node_id)?;
if let Some(ref mut node) = tsn.node_mut() {
let pn = node.as_parent_node_mut()?;
if !pn.unmerged_leaves().contains(&self.own_leaf_index) {
let (public_key, private_key) =
path_secret.derive_key_pair(backend, ciphersuite)?;
if pn.public_key() != &public_key {
return Err(TreeSyncDiffError::PublicKeyMismatch);
} else {
pn.set_private_key(private_key);
path_secret = path_secret.derive_path_secret(backend, ciphersuite)?;
}
};
}
}
Ok(path_secret.into())
}
fn filter_resolution(
&self,
parent_node: &ParentNode,
resolution: &mut Vec<HpkePublicKey>,
) -> Result<(), TreeSyncDiffError> {
for leaf_index in parent_node.unmerged_leaves() {
let leaf_id = self.diff.leaf(*leaf_index)?;
let leaf = self.diff.node(leaf_id)?;
let leaf_node = leaf
.node()
.as_ref()
.ok_or_else(|| LibraryError::custom("filter_resolution(): Node was empty."))?;
let leaf = leaf_node.as_leaf_node()?;
if let Some(position) = resolution
.iter()
.position(|bytes| bytes == leaf.public_key())
{
resolution.remove(position);
};
}
Ok(())
}
fn set_parent_hashes(
&mut self,
backend: &impl OpenMlsCryptoProvider,
ciphersuite: &Ciphersuite,
path: &mut [ParentNode],
leaf_index: LeafIndex,
) -> Result<Vec<u8>, TreeSyncDiffError> {
if path.is_empty() {
return Ok(Vec::new());
}
let mut copath_resolutions = self.copath_resolutions(leaf_index, &HashSet::new())?;
if path.len() != copath_resolutions.len() {
return Err(TreeSyncDiffError::PathLengthError);
}
let mut previous_parent_hash = vec![];
for (path_node, resolution) in path
.iter_mut()
.rev()
.zip(copath_resolutions.iter_mut().rev())
{
path_node.set_parent_hash(previous_parent_hash);
self.filter_resolution(path_node, resolution)?;
let parent_hash = path_node.compute_parent_hash(
backend,
ciphersuite,
path_node.parent_hash(),
resolution,
)?;
previous_parent_hash = parent_hash
}
Ok(previous_parent_hash)
}
fn resolution(
&self,
node_id: NodeId,
excluded_indices: &HashSet<&LeafIndex>,
) -> Result<Vec<HpkePublicKey>, TreeSyncDiffError> {
if let Some(node) = self.diff.node(node_id)?.node() {
if let Some(leaf_index) = self.diff.leaf_index(node_id) {
if excluded_indices.contains(&leaf_index) {
Ok(vec![])
} else {
Ok(vec![node.public_key().clone()])
}
} else {
let mut resolution = vec![node.public_key().clone()];
for leaf_index in node.as_parent_node()?.unmerged_leaves() {
if !excluded_indices.contains(leaf_index) {
let leaf_id = self.diff.leaf(*leaf_index)?;
let leaf = self.diff.node(leaf_id)?;
let leaf_node = leaf
.node()
.as_ref()
.ok_or(TreeSyncDiffError::BlankUnmergedLeaf)?;
resolution.push(leaf_node.public_key().clone())
}
}
Ok(resolution)
}
} else {
if self.diff.is_leaf(node_id) {
Ok(vec![])
} else {
let mut resolution = Vec::new();
let left_child = self.diff.left_child(node_id)?;
let right_child = self.diff.right_child(node_id)?;
resolution.append(&mut self.resolution(left_child, excluded_indices)?);
resolution.append(&mut self.resolution(right_child, excluded_indices)?);
Ok(resolution)
}
}
}
pub(crate) fn copath_resolutions(
&self,
leaf_index: LeafIndex,
excluded_indices: &HashSet<&LeafIndex>,
) -> Result<Vec<Vec<HpkePublicKey>>, TreeSyncDiffError> {
let leaf = self.diff.leaf(leaf_index)?;
if leaf == self.diff.root() {
return Ok(vec![]);
}
let mut full_path = vec![leaf];
let mut direct_path = self.diff.direct_path(leaf_index)?;
if !direct_path.is_empty() {
direct_path.pop();
}
full_path.append(&mut direct_path);
let mut copath_resolutions = Vec::new();
for node_id in &full_path {
let sibling_id = self.diff.sibling(*node_id)?;
let resolution = self.resolution(sibling_id, excluded_indices)?;
copath_resolutions.push(resolution);
}
Ok(copath_resolutions)
}
pub(crate) fn verify_parent_hashes(
&self,
backend: &impl OpenMlsCryptoProvider,
ciphersuite: &Ciphersuite,
) -> Result<(), TreeSyncDiffError> {
for node_id in self.diff.iter() {
if let Some(Node::ParentNode(parent_node)) = self.diff.node(node_id)?.node() {
let left_child_id = self.diff.left_child(node_id)?;
let mut right_child_id = self.diff.right_child(node_id)?;
if let Some(left_child) = self.diff.node(left_child_id)?.node() {
let mut right_child_resolution =
self.resolution(right_child_id, &HashSet::new())?;
self.filter_resolution(parent_node, &mut right_child_resolution)?;
let node_hash = parent_node.compute_parent_hash(
backend,
ciphersuite,
parent_node.parent_hash(),
&right_child_resolution,
)?;
if let Some(left_child_parent_hash) = left_child.parent_hash()? {
if node_hash == left_child_parent_hash {
continue;
};
}
}
while self.diff.node(right_child_id)?.node().is_none()
&& !self.diff.is_leaf(right_child_id)
{
right_child_id = self.diff.left_child(right_child_id)?;
}
if let Some(right_child) = self.diff.node(right_child_id)?.node() {
let mut left_child_resolution =
self.resolution(left_child_id, &HashSet::new())?;
self.filter_resolution(parent_node, &mut left_child_resolution)?;
let node_hash = parent_node.compute_parent_hash(
backend,
ciphersuite,
parent_node.parent_hash(),
&left_child_resolution,
)?;
if let Some(right_child_parent_hash) = right_child.parent_hash()? {
if node_hash == right_child_parent_hash {
continue;
};
}
}
return Err(TreeSyncDiffError::InvalidParentHash);
} else {
continue;
}
}
Ok(())
}
pub(crate) fn into_staged_diff(
mut self,
backend: &impl OpenMlsCryptoProvider,
ciphersuite: &Ciphersuite,
) -> Result<StagedTreeSyncDiff, TreeSyncDiffError> {
let new_tree_hash = self.compute_tree_hashes(backend, ciphersuite)?;
debug_assert!(self.verify_parent_hashes(backend, ciphersuite).is_ok());
Ok(StagedTreeSyncDiff {
own_leaf_index: self.own_leaf_index,
diff: self.diff.into(),
new_tree_hash,
})
}
fn compute_tree_hash(
&mut self,
backend: &impl OpenMlsCryptoProvider,
ciphersuite: &Ciphersuite,
node_id: NodeId,
) -> Result<Vec<u8>, TreeSyncDiffError> {
if let Some(leaf_index) = self.diff.leaf_index(node_id) {
let leaf = self.diff.node_mut(node_id)?;
let tree_hash =
leaf.compute_tree_hash(backend, ciphersuite, Some(leaf_index), 0,vec![], vec![])?;
return Ok(tree_hash);
}
let node = self.diff.node(node_id)?;
if let Some(tree_hash) = node.tree_hash() {
return Ok(tree_hash.to_vec());
}
let left_child = self.diff.left_child(node_id)?;
let left_hash = self.compute_tree_hash(backend, ciphersuite, left_child)?;
let right_child = self.diff.right_child(node_id)?;
let right_hash = self.compute_tree_hash(backend, ciphersuite, right_child)?;
let node = self.diff.node_mut(node_id)?;
let node_index = node_id.node_index();
let tree_hash = node.compute_tree_hash(
backend,
ciphersuite,
None,
node_index,
left_hash,
right_hash,
)?;
Ok(tree_hash)
}
pub(in crate::treesync) fn own_leaf_index(&self) -> LeafIndex {
self.own_leaf_index
}
pub(crate) fn own_leaf(&self) -> Result<&LeafNode, TreeSyncDiffError> {
let leaf_id = self.diff.leaf(self.own_leaf_index)?;
let node = self.diff.node(leaf_id)?;
match node.node() {
Some(node) => Ok(node.as_leaf_node()?),
None => Err(LibraryError::custom("own_leaf(): Node was empty.").into()),
}
}
pub(crate) fn compute_tree_hashes(
&mut self,
backend: &impl OpenMlsCryptoProvider,
ciphersuite: &Ciphersuite,
) -> Result<Vec<u8>, TreeSyncDiffError> {
self.compute_tree_hash(backend, ciphersuite, self.diff.root())
}
pub(crate) fn subtree_root_position(
&self,
leaf_index_1: LeafIndex,
leaf_index_2: LeafIndex,
) -> Result<usize, TreeSyncDiffError> {
Ok(self
.diff
.subtree_root_position(leaf_index_1, leaf_index_2)?)
}
pub(crate) fn decryption_key(
&self,
sender_leaf_index: LeafIndex,
excluded_indices: &HashSet<&LeafIndex>,
) -> Result<(&HpkePrivateKey, usize), TreeSyncDiffError> {
let subtree_root_copath_node_id = self
.diff
.subtree_root_copath_node(sender_leaf_index, self.own_leaf_index)?;
let sender_copath_resolution =
self.resolution(subtree_root_copath_node_id, excluded_indices)?;
let mut own_node_ids = vec![self.diff.leaf(self.own_leaf_index)?];
own_node_ids.append(&mut self.diff.direct_path(self.own_leaf_index)?);
for node_id in own_node_ids {
let node_tsn = self.diff.node(node_id)?;
if let Some(node) = node_tsn.node() {
if let Some(private_key) = node.private_key() {
if let Some(resolution_position) = sender_copath_resolution
.iter()
.position(|pk| pk == node.public_key())
{
return Ok((private_key, resolution_position));
};
}
}
}
Err(TreeSyncDiffError::NoPrivateKeyFound)
}
pub(crate) fn export_nodes(&self) -> Result<Vec<Option<Node>>, TreeSyncDiffError> {
let nodes = self
.diff
.export_nodes()?
.into_iter()
.map(|ts_node| ts_node.node().to_owned())
.collect();
Ok(nodes)
}
pub(crate) fn hash_ref(&self) -> Result<&KeyPackageRef, TreeSyncDiffError> {
let node = self.diff.node(self.diff.leaf(self.own_leaf_index)?)?;
if let Some(Node::LeafNode(node)) = node.node() {
node.key_package_ref().ok_or_else(|| {
TreeSyncDiffError::LibraryError(LibraryError::custom(
"TreeSynDiff::hash_ref(): missing key package ref",
))
})
} else {
Err(TreeSyncDiffError::LibraryError(LibraryError::custom(
"TreeSynDiff::hash_ref(): missing leaf node",
)))
}
}
}
implement_error! {
pub enum TreeSyncDiffError {
Simple {
PathLengthError = "The given path does not have the length of the given leaf's direct path.",
MissingParentHash = "The given key package does not contain a parent hash extension.",
ParentHashMismatch = "The parent hash of the given key package is invalid.",
InvalidParentHash = "The parent hash of a node in the given tree is invalid.",
BlankUnmergedLeaf = "The leaf index in the unmerged leaves of a parent node point to a blank.",
PublicKeyMismatch = "The derived public key doesn't match the one in the tree.",
NoPrivateKeyFound = "Couldn't find a fitting private key in the filtered resolution of the given leaf index.",
}
Complex {
LibraryError(LibraryError) = "A LibraryError occurred.",
NodeTypeError(NodeError) = "We found a node with an unexpected type.",
TreeSyncNodeError(TreeSyncNodeError) = "Error computing tree hash.",
TreeDiffError(MlsBinaryTreeDiffError) = "An error occurred while operating on the diff.",
CryptoError(CryptoError) = "An error occurred during key derivation.",
DerivationError(PathSecretError) = "An error occurred during PathSecret derivation.",
ParentNodeError(ParentNodeError) = "An error occurred during path derivation.",
CreationError(MlsBinaryTreeError) = "An error occurred while creating an empty diff.",
KeyPackageError(KeyPackageError) = "An error occurred while building the leaf node from a key package bundle.",
}
}
}