pub struct WasmKemContext { /* private fields */ }Expand description
WASM-compatible KEM context wrapper
This wrapper provides JavaScript-compatible bindings for KEM operations:
- Integrates with the new modular architecture
- Includes security validation
- Provides consistent error handling
- Supports all KEM algorithms
Implementations§
Source§impl WasmKemContext
impl WasmKemContext
Sourcepub fn new() -> WasmKemContext
pub fn new() -> WasmKemContext
Create a new WASM KEM context with default provider
Sourcepub fn with_provider(provider: &WasmCryptoProvider) -> WasmKemContext
pub fn with_provider(provider: &WasmCryptoProvider) -> WasmKemContext
Create a new WASM KEM context with custom provider
Source§impl WasmKemContext
impl WasmKemContext
Sourcepub fn generate_keypair(
&mut self,
algorithm: &str,
randomness: Option<Uint8Array>,
) -> Result<JsValue, JsValue>
pub fn generate_keypair( &mut self, algorithm: &str, randomness: Option<Uint8Array>, ) -> Result<JsValue, JsValue>
Generate a keypair for the specified algorithm
This method provides secure key generation with:
- Algorithm validation
- Security level verification
- Secure random generation
- Proper error handling
Sourcepub fn encapsulate(
&self,
algorithm: &str,
public_key_data: &Uint8Array,
randomness: Option<Uint8Array>,
) -> Result<JsValue, JsValue>
pub fn encapsulate( &self, algorithm: &str, public_key_data: &Uint8Array, randomness: Option<Uint8Array>, ) -> Result<JsValue, JsValue>
Encapsulate a shared secret using the given public key
This method provides secure encapsulation with:
- Public key validation
- Algorithm verification
- Security level checking
- Proper error handling
Sourcepub fn decapsulate(
&self,
algorithm: &str,
secret_key_data: &Uint8Array,
ciphertext: &Uint8Array,
) -> Result<Vec<u8>, JsValue>
pub fn decapsulate( &self, algorithm: &str, secret_key_data: &Uint8Array, ciphertext: &Uint8Array, ) -> Result<Vec<u8>, JsValue>
Decapsulate a shared secret using the given secret key and ciphertext
This method provides secure decapsulation with:
- Secret key validation
- Ciphertext verification
- Algorithm checking
- Proper error handling
Sourcepub fn security_level(&self) -> u32
pub fn security_level(&self) -> u32
Get the security level of the context
Sourcepub fn is_algorithm_supported(&self, algorithm: &str) -> bool
pub fn is_algorithm_supported(&self, algorithm: &str) -> bool
Check if an algorithm is supported
Sourcepub fn supported_algorithms(&self) -> String
pub fn supported_algorithms(&self) -> String
Get supported algorithms
Trait Implementations§
Source§impl Default for WasmKemContext
impl Default for WasmKemContext
Source§fn default() -> WasmKemContext
fn default() -> WasmKemContext
Returns the “default value” for a type. Read more
Source§impl From<WasmKemContext> for JsValue
impl From<WasmKemContext> for JsValue
Source§fn from(value: WasmKemContext) -> JsValue
fn from(value: WasmKemContext) -> JsValue
Converts to this type from the input type.
Source§impl FromWasmAbi for WasmKemContext
impl FromWasmAbi for WasmKemContext
Source§type Abi = WasmPtr<WasmRefCell<WasmKemContext>>
type Abi = WasmPtr<WasmRefCell<WasmKemContext>>
The Wasm ABI type that this converts from when coming back out from the
ABI boundary.
Source§unsafe fn from_abi(js: <WasmKemContext as FromWasmAbi>::Abi) -> WasmKemContext
unsafe fn from_abi(js: <WasmKemContext as FromWasmAbi>::Abi) -> WasmKemContext
Source§impl IntoWasmAbi for WasmKemContext
impl IntoWasmAbi for WasmKemContext
Source§type Abi = WasmPtr<WasmRefCell<WasmKemContext>>
type Abi = WasmPtr<WasmRefCell<WasmKemContext>>
The Wasm ABI type that this converts into when crossing the ABI
boundary.
Source§fn into_abi(self) -> <WasmKemContext as IntoWasmAbi>::Abi
fn into_abi(self) -> <WasmKemContext as IntoWasmAbi>::Abi
Convert
self into Self::Abi so that it can be sent across the wasm
ABI boundary.Source§impl LongRefFromWasmAbi for WasmKemContext
impl LongRefFromWasmAbi for WasmKemContext
Source§type Abi = WasmPtr<WasmRefCell<WasmKemContext>>
type Abi = WasmPtr<WasmRefCell<WasmKemContext>>
Same as
RefFromWasmAbi::AbiSource§type Anchor = RcRef<WasmKemContext>
type Anchor = RcRef<WasmKemContext>
Same as
RefFromWasmAbi::AnchorSource§unsafe fn long_ref_from_abi(
js: <WasmKemContext as LongRefFromWasmAbi>::Abi,
) -> <WasmKemContext as LongRefFromWasmAbi>::Anchor
unsafe fn long_ref_from_abi( js: <WasmKemContext as LongRefFromWasmAbi>::Abi, ) -> <WasmKemContext as LongRefFromWasmAbi>::Anchor
Same as
RefFromWasmAbi::ref_from_abiSource§impl OptionFromWasmAbi for WasmKemContext
impl OptionFromWasmAbi for WasmKemContext
Source§fn is_none(abi: &<WasmKemContext as FromWasmAbi>::Abi) -> bool
fn is_none(abi: &<WasmKemContext as FromWasmAbi>::Abi) -> bool
Tests whether the argument is a “none” instance. If so it will be
deserialized as
None, and otherwise it will be passed to
FromWasmAbi.Source§impl OptionIntoWasmAbi for WasmKemContext
impl OptionIntoWasmAbi for WasmKemContext
Source§fn none() -> <WasmKemContext as IntoWasmAbi>::Abi
fn none() -> <WasmKemContext as IntoWasmAbi>::Abi
Returns an ABI instance indicating “none”, which JS will interpret as
the
None branch of this option. Read moreSource§impl RefFromWasmAbi for WasmKemContext
impl RefFromWasmAbi for WasmKemContext
Source§type Abi = WasmPtr<WasmRefCell<WasmKemContext>>
type Abi = WasmPtr<WasmRefCell<WasmKemContext>>
The Wasm ABI type references to
Self are recovered from.Source§type Anchor = RcRef<WasmKemContext>
type Anchor = RcRef<WasmKemContext>
The type that holds the reference to
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§unsafe fn ref_from_abi(
js: <WasmKemContext as RefFromWasmAbi>::Abi,
) -> <WasmKemContext as RefFromWasmAbi>::Anchor
unsafe fn ref_from_abi( js: <WasmKemContext as RefFromWasmAbi>::Abi, ) -> <WasmKemContext as RefFromWasmAbi>::Anchor
Source§impl RefMutFromWasmAbi for WasmKemContext
impl RefMutFromWasmAbi for WasmKemContext
Source§type Abi = WasmPtr<WasmRefCell<WasmKemContext>>
type Abi = WasmPtr<WasmRefCell<WasmKemContext>>
Same as
RefFromWasmAbi::AbiSource§type Anchor = RcRefMut<WasmKemContext>
type Anchor = RcRefMut<WasmKemContext>
Same as
RefFromWasmAbi::AnchorSource§unsafe fn ref_mut_from_abi(
js: <WasmKemContext as RefMutFromWasmAbi>::Abi,
) -> <WasmKemContext as RefMutFromWasmAbi>::Anchor
unsafe fn ref_mut_from_abi( js: <WasmKemContext as RefMutFromWasmAbi>::Abi, ) -> <WasmKemContext as RefMutFromWasmAbi>::Anchor
Same as
RefFromWasmAbi::ref_from_abiSource§impl TryFromJsValue for WasmKemContext
impl TryFromJsValue for WasmKemContext
Source§fn try_from_js_value(value: JsValue) -> Result<WasmKemContext, JsValue>
fn try_from_js_value(value: JsValue) -> Result<WasmKemContext, JsValue>
Performs the conversion.
Source§fn try_from_js_value_ref(value: &JsValue) -> Option<WasmKemContext>
fn try_from_js_value_ref(value: &JsValue) -> Option<WasmKemContext>
Performs the conversion.
Source§impl VectorFromWasmAbi for WasmKemContext
impl VectorFromWasmAbi for WasmKemContext
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi( js: <WasmKemContext as VectorFromWasmAbi>::Abi, ) -> Box<[WasmKemContext]>
Source§impl VectorIntoWasmAbi for WasmKemContext
impl VectorIntoWasmAbi for WasmKemContext
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi( vector: Box<[WasmKemContext]>, ) -> <WasmKemContext as VectorIntoWasmAbi>::Abi
Auto Trait Implementations§
impl Freeze for WasmKemContext
impl !RefUnwindSafe for WasmKemContext
impl Send for WasmKemContext
impl Sync for WasmKemContext
impl Unpin for WasmKemContext
impl UnsafeUnpin for WasmKemContext
impl !UnwindSafe for WasmKemContext
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.