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§
Sourcefn signer_create(
algorithm: &str,
secret_key: &[u8],
opts: Option<OptionView<'_>>,
) -> PluginResult<Self>
fn signer_create( algorithm: &str, secret_key: &[u8], opts: Option<OptionView<'_>>, ) -> PluginResult<Self>
Construct a signer from the secret key.
Sourcefn verifier_create(
algorithm: &str,
public_key: &[u8],
opts: Option<OptionView<'_>>,
) -> PluginResult<Self>
fn verifier_create( algorithm: &str, public_key: &[u8], opts: Option<OptionView<'_>>, ) -> PluginResult<Self>
Construct a verifier from the public key.
Sourcefn set_hash(&mut self, hash_name: &str) -> PluginResult<()>
fn set_hash(&mut self, hash_name: &str) -> PluginResult<()>
Set the hash algorithm used for signing/verifying (for hash-then-sign schemes).
Sourcefn update(&mut self, data: &[u8]) -> PluginResult<()>
fn update(&mut self, data: &[u8]) -> PluginResult<()>
Absorb message bytes into the signing/verification context.
Sourcefn signer_finalize(&mut self, sig_out: &mut [u8]) -> PluginResult<usize>
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.
Sourcefn verifier_finalize(&mut self, signature: &[u8]) -> PluginResult<()>
fn verifier_finalize(&mut self, signature: &[u8]) -> PluginResult<()>
Finalize verification: return Ok(()) if the signature is
valid.
Sourcefn keypair_generate(
algorithm: &str,
seed: Option<&[u8]>,
opts: Option<OptionView<'_>>,
) -> PluginResult<SignatureKeypair>
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".