paas_api/transcrypt.rs
1use libpep::data::traits::{Pseudonymizable, Rekeyable, Transcryptable};
2use libpep::factors::{EncryptionContext, PseudonymizationDomain};
3use serde::{Deserialize, Serialize};
4
5#[derive(Serialize, Deserialize, Debug)]
6/// An API request to transcrypt an encrypted pseudonym.
7pub struct PseudonymizationRequest<T: Pseudonymizable> {
8 /// The encrypted pseudonym.
9 pub encrypted: T,
10 /// The domain of the encrypted pseudonym.
11 pub domain_from: PseudonymizationDomain,
12 /// The domain to transcrypt the pseudonym to.
13 pub domain_to: PseudonymizationDomain,
14 /// The session the pseudonym was encrypted in associated with this server.
15 pub session_from: EncryptionContext,
16 /// The session the pseudonym should be decryptable in associated with this server.
17 pub session_to: EncryptionContext,
18}
19
20#[derive(Serialize, Deserialize)]
21pub struct PseudonymizationResponse<T: Pseudonymizable> {
22 /// The transcrypted pseudonym.
23 pub result: T,
24}
25
26#[derive(Serialize, Deserialize, Debug)]
27/// An API request to transcrypt a batch of encrypted pseudonyms.
28pub struct PseudonymizationBatchRequest<T: Pseudonymizable> {
29 /// The encrypted pseudonyms.
30 pub encrypted: Vec<T>,
31 /// The domain of the encrypted pseudonyms.
32 pub domain_from: PseudonymizationDomain,
33 /// The domain to transcrypt the pseudonyms to.
34 pub domain_to: PseudonymizationDomain,
35 /// The session the pseudonyms were encrypted in associated with this server.
36 pub session_from: EncryptionContext,
37 /// The session the pseudonyms should be decryptable in associated with this server.
38 pub session_to: EncryptionContext,
39}
40
41#[derive(Serialize, Deserialize)]
42pub struct PseudonymizationBatchResponse<T: Pseudonymizable> {
43 /// The transcrypted pseudonyms.
44 /// Watch out: the order may be randomly permuted to break linkability.
45 pub result: Vec<T>,
46}
47
48#[derive(Serialize, Deserialize, Debug)]
49/// An API request to rekey an encrypted attribute.
50pub struct RekeyRequest<T: Rekeyable> {
51 /// The encrypted data.
52 pub encrypted: T,
53 /// The session the attribute was encrypted in associated with this server.
54 pub session_from: EncryptionContext,
55 /// The session the attribute should be decryptable in associated with this server.
56 pub session_to: EncryptionContext,
57}
58
59#[derive(Serialize, Deserialize)]
60pub struct RekeyResponse<T: Rekeyable> {
61 /// The rekeyed attribute.
62 pub result: T,
63}
64
65#[derive(Serialize, Deserialize, Debug)]
66/// An API request to rekey a batch of encrypted attributes.
67pub struct RekeyBatchRequest<T: Rekeyable> {
68 /// The encrypted data.
69 pub encrypted: Vec<T>,
70 /// The session the attributes were encrypted in associated with this server.
71 pub session_from: EncryptionContext,
72 /// The session the attributes should be decryptable in associated with this server.
73 pub session_to: EncryptionContext,
74}
75
76#[derive(Serialize, Deserialize)]
77pub struct RekeyBatchResponse<T: Rekeyable> {
78 /// The rekeyed attributes.
79 pub result: Vec<T>,
80}
81
82#[derive(Serialize, Deserialize, Debug)]
83/// An API request to transcrypt encrypted data.
84pub struct TranscryptionRequest<T: Transcryptable> {
85 /// The encrypted data.
86 pub encrypted: T,
87 /// The domain of the encrypted pseudonyms.
88 pub domain_from: PseudonymizationDomain,
89 /// The domain to transcrypt the pseudonyms to.
90 pub domain_to: PseudonymizationDomain,
91 /// The session the messages were encrypted in associated with this server.
92 pub session_from: EncryptionContext,
93 /// The session the messages should be decryptable in associated with this server.
94 pub session_to: EncryptionContext,
95}
96
97#[derive(Serialize, Deserialize)]
98pub struct TranscryptionResponse<T: Transcryptable> {
99 /// The transcrypted data.
100 pub result: T,
101}
102
103#[derive(Serialize, Deserialize, Debug)]
104/// An API request to transcrypt a batch of encrypted data.
105pub struct TranscryptionBatchRequest<T: Transcryptable> {
106 /// The encrypted data.
107 pub encrypted: Vec<T>,
108 /// The domain of the encrypted pseudonyms.
109 pub domain_from: PseudonymizationDomain,
110 /// The domain to transcrypt the pseudonyms to.
111 pub domain_to: PseudonymizationDomain,
112 /// The session the messages were encrypted in associated with this server.
113 pub session_from: EncryptionContext,
114 /// The session the messages should be decryptable in associated with this server.
115 pub session_to: EncryptionContext,
116}
117
118#[derive(Serialize, Deserialize)]
119pub struct TranscryptionBatchResponse<T: Transcryptable> {
120 /// The transcrypted data.
121 /// Watch out: the order may be randomly permuted to break linkability.
122 pub result: Vec<T>,
123}