pub struct WasmSignatureContext { /* private fields */ }Expand description
WASM-compatible Signature context wrapper
This wrapper provides JavaScript-compatible bindings for signature operations:
- Integrates with the new modular architecture
- Includes security validation
- Provides consistent error handling
- Supports all signature algorithms
Implementations§
Source§impl WasmSignatureContext
impl WasmSignatureContext
Sourcepub fn new() -> WasmSignatureContext
pub fn new() -> WasmSignatureContext
Create a new WASM Signature context with default provider
Prefer Self::from_signature_context when building from the lib-q crate so that
real signature implementations (e.g. lib-q-sig) are wired in instead of the core stub.
Sourcepub fn from_signature_context(inner: SignatureContext) -> WasmSignatureContext
pub fn from_signature_context(inner: SignatureContext) -> WasmSignatureContext
Wrap a Rust SignatureContext (for example one built with
SignatureContext::with_provider(Box::new(lib_q_sig::LibQSignatureProvider::new()?))).
Source§impl WasmSignatureContext
impl WasmSignatureContext
Sourcepub fn with_provider(provider: &WasmCryptoProvider) -> WasmSignatureContext
pub fn with_provider(provider: &WasmCryptoProvider) -> WasmSignatureContext
Create a new WASM Signature context with custom provider
Source§impl WasmSignatureContext
impl WasmSignatureContext
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
Sourcepub fn sign(
&self,
algorithm: &str,
secret_key_data: &Uint8Array,
message: &Uint8Array,
randomness: Option<Uint8Array>,
) -> Result<Vec<u8>, JsValue>
pub fn sign( &self, algorithm: &str, secret_key_data: &Uint8Array, message: &Uint8Array, randomness: Option<Uint8Array>, ) -> Result<Vec<u8>, JsValue>
Sign a message using the given secret key
Sourcepub fn verify(
&self,
algorithm: &str,
public_key_data: &Uint8Array,
message: &Uint8Array,
signature: &Uint8Array,
) -> Result<bool, JsValue>
pub fn verify( &self, algorithm: &str, public_key_data: &Uint8Array, message: &Uint8Array, signature: &Uint8Array, ) -> Result<bool, JsValue>
Verify a signature using the given public key
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 WasmSignatureContext
impl Default for WasmSignatureContext
Source§impl From<WasmSignatureContext> for JsValue
impl From<WasmSignatureContext> for JsValue
Source§fn from(value: WasmSignatureContext) -> Self
fn from(value: WasmSignatureContext) -> Self
Source§impl FromWasmAbi for WasmSignatureContext
impl FromWasmAbi for WasmSignatureContext
Source§impl IntoWasmAbi for WasmSignatureContext
impl IntoWasmAbi for WasmSignatureContext
Source§impl LongRefFromWasmAbi for WasmSignatureContext
impl LongRefFromWasmAbi for WasmSignatureContext
Source§type Abi = WasmPtr<WasmRefCell<WasmSignatureContext>>
type Abi = WasmPtr<WasmRefCell<WasmSignatureContext>>
RefFromWasmAbi::AbiSource§type Anchor = RcRef<WasmSignatureContext>
type Anchor = RcRef<WasmSignatureContext>
RefFromWasmAbi::AnchorSource§unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
RefFromWasmAbi::ref_from_abiSource§impl RefFromWasmAbi for WasmSignatureContext
impl RefFromWasmAbi for WasmSignatureContext
Source§type Abi = WasmPtr<WasmRefCell<WasmSignatureContext>>
type Abi = WasmPtr<WasmRefCell<WasmSignatureContext>>
Self are recovered from.Source§type Anchor = RcRef<WasmSignatureContext>
type Anchor = RcRef<WasmSignatureContext>
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 WasmSignatureContext
impl RefMutFromWasmAbi for WasmSignatureContext
Source§type Abi = WasmPtr<WasmRefCell<WasmSignatureContext>>
type Abi = WasmPtr<WasmRefCell<WasmSignatureContext>>
RefFromWasmAbi::AbiSource§type Anchor = RcRefMut<WasmSignatureContext>
type Anchor = RcRefMut<WasmSignatureContext>
RefFromWasmAbi::AnchorSource§unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
RefFromWasmAbi::ref_from_abiSource§impl VectorFromWasmAbi for WasmSignatureContext
impl VectorFromWasmAbi for WasmSignatureContext
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[WasmSignatureContext]>
Source§impl VectorIntoWasmAbi for WasmSignatureContext
impl VectorIntoWasmAbi for WasmSignatureContext
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[WasmSignatureContext]>) -> Self::Abi
Source§impl WasmDescribeVector for WasmSignatureContext
impl WasmDescribeVector for WasmSignatureContext
impl SupportsConstructor for WasmSignatureContext
impl SupportsInstanceProperty for WasmSignatureContext
impl SupportsStaticProperty for WasmSignatureContext
Auto Trait Implementations§
impl Freeze for WasmSignatureContext
impl !RefUnwindSafe for WasmSignatureContext
impl Send for WasmSignatureContext
impl Sync for WasmSignatureContext
impl Unpin for WasmSignatureContext
impl UnsafeUnpin for WasmSignatureContext
impl !UnwindSafe for WasmSignatureContext
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
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
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.