pub struct PublicKey(/* private fields */);Expand description
The public component of the encapsulation key. This is usually the key of the recipient.
For X-Wing, the key is 1216 bytes (1184 bytes for ML-KEM-768 and 32 bytes for X25519).
Implementations§
Source§impl PublicKey
impl PublicKey
Sourcepub fn seal(
recipient: &PublicKey,
plaintext: &[u8],
info: Option<&[u8]>,
) -> Result<Vec<u8>, Error>
pub fn seal( recipient: &PublicKey, plaintext: &[u8], info: Option<&[u8]>, ) -> Result<Vec<u8>, Error>
Seal plaintext to the recipient’s public key. This is analogous to
libsodium’s Sealed Box where
a message is sent anonymously to a recipient’s public key. The important difference is that a hybrid KEM
is used.
With the choice of X-Wing, the ciphertext remains IND-CCA secure as long as either the security
properties of X25519 or ML-KEM-768 (Kyber768) holds.
§Arguments
recipient: The public key of the recipient.plaintext: The plaintext message to be encrypted.info: Optional application-supplied information. This is usually global context (e.g. “a backup of X app”). The exact sameinfomust be provided for sealing and unsealing, otherwise unsealing will fail.
§Errors
Error::Rngif the operating system CSPRNG is unavailable.Error::InfoExceedsSizeifinfois larger than the permitted maximum.Error::Sealif HPKE encapsulation or AEAD sealing unexpectedly fails.
§Panics
An unavailable OS CSPRNG is reported as Error::Rng via an internal
readiness check. A panic is only reachable in the residual window where
the CSPRNG passes that check and then fails mid-encapsulation.
§Wire Format
HEADER || ENCAPSULATED_KEY || CIPHERTEXTTrait Implementations§
impl Eq for PublicKey
impl StructuralPartialEq for PublicKey
Auto Trait Implementations§
impl Freeze for PublicKey
impl RefUnwindSafe for PublicKey
impl Send for PublicKey
impl Sync for PublicKey
impl Unpin for PublicKey
impl UnsafeUnpin for PublicKey
impl UnwindSafe for PublicKey
Blanket Implementations§
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
Mutably borrows from an owned value. Read more