core_utils/key_recovery/mod.rs
1use serde::{Deserialize, Serialize};
2
3/// Upper bound on the number of peers supported for the MXE key recovery.
4/// The block length n of the Reed-Solomon code is at most N.
5pub const MXE_KEY_RECOVERY_N: usize = 100;
6
7/// Upper bound on the message length k of the Reed-Solomon code.
8/// If an adversary controls k or more peers then he can reconstruct the key shares.
9/// If the number of controlled peers is greater than (d-1)/2 then the adversary can
10/// sabotage the key recovery and the peers will never get caught.
11pub const MXE_KEY_RECOVERY_K: usize = (MXE_KEY_RECOVERY_N - 1) / 3 + 1;
12
13/// Upper bound on the distance d of the Reed-Solomon code.
14/// The key recovery can identify and correct up to (d-1)/2 corrupt peers.
15/// If n mod 3 = 0 then k = (d-1)/2, i.e., if an adversary controls k peers then
16/// the key is recoverable (the corrupt peers can be identified), but the MXE is
17/// expected to be compromised.
18pub const MXE_KEY_RECOVERY_D: usize = MXE_KEY_RECOVERY_N - MXE_KEY_RECOVERY_K + 1;
19
20#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, thiserror::Error)]
21pub enum KeyRecoveryError {
22 #[error("Invalid input: {0}")]
23 InvalidInput(String),
24 #[error("Failed recovery: {0}")]
25 FailedRecovery(String),
26}
27
28pub mod compute_errors;