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§impl From<WasmKemContext> for JsValue
impl From<WasmKemContext> for JsValue
Source§fn from(value: WasmKemContext) -> Self
fn from(value: WasmKemContext) -> Self
Converts to this type from the input type.
Source§impl FromWasmAbi for WasmKemContext
impl FromWasmAbi for WasmKemContext
Source§impl IntoWasmAbi for WasmKemContext
impl IntoWasmAbi for WasmKemContext
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: Self::Abi) -> Self::Anchor
unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
Same as
RefFromWasmAbi::ref_from_abiSource§impl OptionFromWasmAbi for WasmKemContext
impl OptionFromWasmAbi for WasmKemContext
Source§impl OptionIntoWasmAbi for WasmKemContext
impl OptionIntoWasmAbi for WasmKemContext
Source§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§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: Self::Abi) -> Self::Anchor
unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
Same as
RefFromWasmAbi::ref_from_abiSource§impl TryFromJsValue for WasmKemContext
impl TryFromJsValue for WasmKemContext
Source§impl VectorFromWasmAbi for WasmKemContext
impl VectorFromWasmAbi for WasmKemContext
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::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]>) -> Self::Abi
Source§impl WasmDescribeVector for WasmKemContext
impl WasmDescribeVector for WasmKemContext
impl SupportsConstructor for WasmKemContext
impl SupportsInstanceProperty for WasmKemContext
impl SupportsStaticProperty for WasmKemContext
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> 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.