pub struct HpkeContext {
private_key: StaticSecret,
}Expand description
A context for performing E2E encryption using X25519 and ChaCha20Poly1305.
Fields§
§private_key: StaticSecretImplementations§
Source§impl HpkeContext
impl HpkeContext
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Generates a new keypair.
This will create a new HpkeContext with a randomly generated X25519 keypair.
§Errors
This function will return an error if the key generation fails.
Sourcepub fn from_private_key(private_key_bytes: &[u8]) -> Result<Self>
pub fn from_private_key(private_key_bytes: &[u8]) -> Result<Self>
Sourcepub fn public_key_bytes(&self) -> Vec<u8> ⓘ
pub fn public_key_bytes(&self) -> Vec<u8> ⓘ
Returns the public key bytes corresponding to our private key.
Sourcepub fn private_key_bytes(&self) -> Vec<u8> ⓘ
pub fn private_key_bytes(&self) -> Vec<u8> ⓘ
Returns the private key bytes.
Sourcefn parse_public_key(&self, key_bytes: &[u8]) -> Result<PublicKey>
fn parse_public_key(&self, key_bytes: &[u8]) -> Result<PublicKey>
Parses a public key from a byte slice.
Sourcefn derive_symmetric_key(&self, shared_secret: &SharedSecret) -> Key
fn derive_symmetric_key(&self, shared_secret: &SharedSecret) -> Key
Derives a symmetric key from a shared secret.
Auto Trait Implementations§
impl Freeze for HpkeContext
impl RefUnwindSafe for HpkeContext
impl Send for HpkeContext
impl Sync for HpkeContext
impl Unpin for HpkeContext
impl UnwindSafe for HpkeContext
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more