KEM

Struct KEM 

Source
pub struct KEM<K> { /* private fields */ }
Expand description

Key-encapsulation mechanism (ref Algorithm 2, Section 1.3.10)

Implementations§

Source§

impl<K: FiniteField + Clone + Debug> KEM<K>

Source

pub fn setup(params: PublicParameters<K>) -> Self

Initialise the KEM

Source

pub fn keygen(&self) -> Result<(Vec<u8>, SecretKey, PublicKey<K>), String>

Generate a secret and a keypair

Source

pub fn encaps(&self, pk: &PublicKey<K>) -> Result<(Ciphertext, Vec<u8>), String>

Encapsulate the shared secret using the PKE encryption

Source

pub fn decaps( &self, s: &[u8], sk: &SecretKey, pk: &PublicKey<K>, c: Ciphertext, ) -> Result<Vec<u8>, String>

Decapsulate the shared secret using the PKE decryption

Auto Trait Implementations§

§

impl<K> Freeze for KEM<K>
where K: Freeze,

§

impl<K> RefUnwindSafe for KEM<K>
where K: RefUnwindSafe,

§

impl<K> Send for KEM<K>
where K: Send,

§

impl<K> Sync for KEM<K>
where K: Sync,

§

impl<K> Unpin for KEM<K>
where K: Unpin,

§

impl<K> UnwindSafe for KEM<K>
where K: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.