pub struct PublicKey(/* private fields */);Expand description
A crypto_box public key.
This type can be serialized if the serde feature is enabled.
Implementations§
Source§impl PublicKey
impl PublicKey
Sourcepub fn from_bytes(bytes: [u8; 32]) -> Self
pub fn from_bytes(bytes: [u8; 32]) -> Self
Initialize PublicKey from a byte array.
Sourcepub fn from_slice(slice: &[u8]) -> Result<Self, TryFromSliceError>
pub fn from_slice(slice: &[u8]) -> Result<Self, TryFromSliceError>
Initialize PublicKey from a byte slice.
Returns TryFromSliceError if the slice length is not exactly equal
to KEY_SIZE.
Sourcepub fn seal(
&self,
csprng: &mut impl CryptoRngCore,
plaintext: &[u8],
) -> Result<Vec<u8>, Error>
Available on crate feature seal only.
pub fn seal( &self, csprng: &mut impl CryptoRngCore, plaintext: &[u8], ) -> Result<Vec<u8>, Error>
seal only.Implementation of crypto_box_seal function from libsodium “sealed boxes”.
Sealed boxes are designed to anonymously send messages to a recipient given their public key.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for PublicKey
Available on crate feature serde only.
impl<'de> Deserialize<'de> for PublicKey
Available on crate feature
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<MontgomeryPoint> for PublicKey
impl From<MontgomeryPoint> for PublicKey
Source§fn from(value: MontgomeryPoint) -> Self
fn from(value: MontgomeryPoint) -> Self
Converts to this type from the input type.
Source§impl Ord for PublicKey
impl Ord for PublicKey
Source§impl PartialOrd for PublicKey
impl PartialOrd for PublicKey
Source§impl TryFrom<&[u8]> for PublicKey
impl TryFrom<&[u8]> for PublicKey
Source§type Error = TryFromSliceError
type Error = TryFromSliceError
The type returned in the event of a conversion error.
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 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