-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathmod.rs
More file actions
64 lines (55 loc) · 1.89 KB
/
Copy pathmod.rs
File metadata and controls
64 lines (55 loc) · 1.89 KB
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
use crate::cryptography::encryption::UnifiedCipher;
use kms_grpc::rpc_types::PrivDataType;
use serde::{Deserialize, Serialize};
use tfhe_versionable::{Versionize, VersionsDispatch};
pub mod custodian;
pub mod error;
pub mod operator;
pub mod secretsharing;
pub mod seed_phrase;
use crate::cryptography::signcryption::UnifiedSigncryption;
use kms_grpc::RequestId;
use kms_grpc::kms::v1::OperatorBackupOutput;
use tfhe::named::Named;
#[cfg(test)]
mod tests;
pub const KMS_CUSTODIAN: &str = "kms-custodian";
pub const SEED_PHRASE_DESC: &str = "The SECRET seed phrase for the custodian keys is: ";
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize, VersionsDispatch)]
pub enum BackupCiphertextVersions {
V0(BackupCiphertext),
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Versionize)]
#[versionize(BackupCiphertextVersions)]
pub struct BackupCiphertext {
pub ciphertext: UnifiedCipher,
pub priv_data_type: PrivDataType,
pub backup_id: RequestId,
}
impl Named for BackupCiphertext {
const NAME: &'static str = "cryptography::BackupCiphertext";
}
impl TryFrom<OperatorBackupOutput> for UnifiedSigncryption {
type Error = anyhow::Error;
fn try_from(value: OperatorBackupOutput) -> Result<Self, Self::Error> {
let pke_type = value.pke_type().into();
let signing_type = value.signing_type().into();
Ok(UnifiedSigncryption::new(
value.signcryption,
pke_type,
signing_type,
))
}
}
impl TryFrom<&OperatorBackupOutput> for UnifiedSigncryption {
type Error = anyhow::Error;
fn try_from(value: &OperatorBackupOutput) -> Result<Self, Self::Error> {
let pke_type = value.pke_type.try_into()?;
let signing_type = value.signing_type.try_into()?;
Ok(UnifiedSigncryption::new(
value.signcryption.clone(),
pke_type,
signing_type,
))
}
}