Skip to main content

SignaturePlugin

Trait SignaturePlugin 

Source
pub trait SignaturePlugin: Sized {
    // Required methods
    fn signer_create(
        algorithm: &str,
        secret_key: &[u8],
        opts: Option<OptionView<'_>>,
    ) -> PluginResult<Self>;
    fn verifier_create(
        algorithm: &str,
        public_key: &[u8],
        opts: Option<OptionView<'_>>,
    ) -> PluginResult<Self>;
    fn set_hash(&mut self, hash_name: &str) -> PluginResult<()>;
    fn update(&mut self, data: &[u8]) -> PluginResult<()>;
    fn signer_finalize(&mut self, sig_out: &mut [u8]) -> PluginResult<usize>;
    fn verifier_finalize(&mut self, signature: &[u8]) -> PluginResult<()>;
    fn keypair_generate(
        algorithm: &str,
        seed: Option<&[u8]>,
        opts: Option<OptionView<'_>>,
    ) -> PluginResult<SignatureKeypair>;
}
Expand description

Trait implemented by signature plugins. The type Self serves as both the signer and verifier state — the plugin dispatches internally based on which entry points are called.

Required Methods§

Source

fn signer_create( algorithm: &str, secret_key: &[u8], opts: Option<OptionView<'_>>, ) -> PluginResult<Self>

Construct a signer from the secret key.

Source

fn verifier_create( algorithm: &str, public_key: &[u8], opts: Option<OptionView<'_>>, ) -> PluginResult<Self>

Construct a verifier from the public key.

Source

fn set_hash(&mut self, hash_name: &str) -> PluginResult<()>

Set the hash algorithm used for signing/verifying (for hash-then-sign schemes).

Source

fn update(&mut self, data: &[u8]) -> PluginResult<()>

Absorb message bytes into the signing/verification context.

Source

fn signer_finalize(&mut self, sig_out: &mut [u8]) -> PluginResult<usize>

Finalize signing: write the signature into sig_out. Returns the number of bytes written.

Source

fn verifier_finalize(&mut self, signature: &[u8]) -> PluginResult<()>

Finalize verification: return Ok(()) if the signature is valid.

Source

fn keypair_generate( algorithm: &str, seed: Option<&[u8]>, opts: Option<OptionView<'_>>, ) -> PluginResult<SignatureKeypair>

Generate a keypair for the named algorithm. If seed is provided, it is used deterministically; otherwise the plugin generates fresh randomness.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§