pub struct Envelope { /* private fields */ }Expand description
The envelope structure that holds the encrypted data along with the necessary metadata.
Implementations§
Source§impl Envelope
impl Envelope
Sourcepub fn new<B: AsRef<[u8]>>(
recipients: &[PublicKey],
data: B,
data_encryption_key: Option<[u8; 32]>,
) -> Result<Self>
pub fn new<B: AsRef<[u8]>>( recipients: &[PublicKey], data: B, data_encryption_key: Option<[u8; 32]>, ) -> Result<Self>
Create a new envelope for the given recipients with the specified data.
Optionally, an already existing data encryption key can be provided. However, if it is not provided, a new one will be created.
Sourcepub fn recipients(&self) -> &[Recipient]
pub fn recipients(&self) -> &[Recipient]
Return the list of recipients that can decrypt the data
Sourcepub fn ciphertext(&self) -> &[u8] ⓘ
pub fn ciphertext(&self) -> &[u8] ⓘ
Return the encrypted data
Sourcepub fn decrypt_by_recipient_secret_key(
&self,
recipient_secret_key: &SecretKey,
) -> Result<Vec<u8>>
pub fn decrypt_by_recipient_secret_key( &self, recipient_secret_key: &SecretKey, ) -> Result<Vec<u8>>
Decrypt the envelope using the recipient’s secret key
This method will attempt to decrypt the envelope using each recipient’s capsule until one succeeds. If none succeed, an error is returned.
Sourcepub fn decrypt_by_recipient_index(
&self,
index: usize,
recipient_secret_key: &SecretKey,
) -> Result<Vec<u8>>
pub fn decrypt_by_recipient_index( &self, index: usize, recipient_secret_key: &SecretKey, ) -> Result<Vec<u8>>
Decrypt the envelope using the recipient’s index and secret key
This method will attempt to decrypt the envelope using the recipient at the specified index. If the index is out of bounds or the decryption fails, an error is returned
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Envelope
impl<'de> Deserialize<'de> for Envelope
Source§fn deserialize<D>(d: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(d: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Envelope
impl RefUnwindSafe for Envelope
impl Send for Envelope
impl Sync for Envelope
impl Unpin for Envelope
impl UnwindSafe for Envelope
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.