holochain_integrity_types/
x_salsa20_poly1305.rs

1use crate::prelude::*;
2pub mod data;
3pub mod encrypted_data;
4pub mod key_ref;
5pub mod nonce;
6pub mod x25519;
7use holochain_serialized_bytes::prelude::*;
8
9#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, SerializedBytes)]
10pub struct XSalsa20Poly1305Decrypt {
11    pub key_ref: crate::x_salsa20_poly1305::key_ref::XSalsa20Poly1305KeyRef,
12    pub encrypted_data: crate::x_salsa20_poly1305::encrypted_data::XSalsa20Poly1305EncryptedData,
13}
14
15impl XSalsa20Poly1305Decrypt {
16    pub fn new(
17        key_ref: crate::x_salsa20_poly1305::key_ref::XSalsa20Poly1305KeyRef,
18        encrypted_data: crate::x_salsa20_poly1305::encrypted_data::XSalsa20Poly1305EncryptedData,
19    ) -> Self {
20        Self {
21            key_ref,
22            encrypted_data,
23        }
24    }
25
26    pub fn as_key_ref_ref(&self) -> &crate::x_salsa20_poly1305::key_ref::XSalsa20Poly1305KeyRef {
27        &self.key_ref
28    }
29
30    pub fn as_encrypted_data_ref(
31        &self,
32    ) -> &crate::x_salsa20_poly1305::encrypted_data::XSalsa20Poly1305EncryptedData {
33        &self.encrypted_data
34    }
35}
36
37#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, SerializedBytes)]
38pub struct X25519XSalsa20Poly1305Decrypt {
39    pub recipient: X25519PubKey,
40    pub sender: X25519PubKey,
41    pub encrypted_data: XSalsa20Poly1305EncryptedData,
42}
43
44impl X25519XSalsa20Poly1305Decrypt {
45    pub fn new(
46        recipient: X25519PubKey,
47        sender: X25519PubKey,
48        encrypted_data: XSalsa20Poly1305EncryptedData,
49    ) -> Self {
50        Self {
51            recipient,
52            sender,
53            encrypted_data,
54        }
55    }
56
57    pub fn as_sender_ref(&self) -> &X25519PubKey {
58        &self.sender
59    }
60
61    pub fn as_recipient_ref(&self) -> &X25519PubKey {
62        &self.recipient
63    }
64
65    pub fn as_encrypted_data_ref(&self) -> &XSalsa20Poly1305EncryptedData {
66        &self.encrypted_data
67    }
68}
69
70#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, SerializedBytes)]
71pub struct Ed25519XSalsa20Poly1305Decrypt {
72    pub recipient: AgentPubKey,
73    pub sender: AgentPubKey,
74    pub encrypted_data: XSalsa20Poly1305EncryptedData,
75}
76
77impl Ed25519XSalsa20Poly1305Decrypt {
78    pub fn new(
79        recipient: AgentPubKey,
80        sender: AgentPubKey,
81        encrypted_data: XSalsa20Poly1305EncryptedData,
82    ) -> Self {
83        Self {
84            recipient,
85            sender,
86            encrypted_data,
87        }
88    }
89
90    pub fn as_sender_ref(&self) -> &AgentPubKey {
91        &self.sender
92    }
93
94    pub fn as_recipient_ref(&self) -> &AgentPubKey {
95        &self.recipient
96    }
97
98    pub fn as_encrypted_data_ref(&self) -> &XSalsa20Poly1305EncryptedData {
99        &self.encrypted_data
100    }
101}