Skip to main content

KeyManager

Trait KeyManager 

Source
pub trait KeyManager {
    // Required methods
    fn generate_keys(&mut self) -> Result<(), JacsError>;
    fn sign_string(&mut self, data: &str) -> Result<String, JacsError>;
    fn verify_string(
        &self,
        data: &str,
        signature_base64: &str,
        public_key: Vec<u8>,
        public_key_enc_type: Option<String>,
    ) -> Result<(), JacsError>;
    fn sign_batch(
        &mut self,
        messages: &[&str],
    ) -> Result<Vec<String>, JacsError>;
}

Required Methods§

Source

fn generate_keys(&mut self) -> Result<(), JacsError>

Source

fn sign_string(&mut self, data: &str) -> Result<String, JacsError>

Source

fn verify_string( &self, data: &str, signature_base64: &str, public_key: Vec<u8>, public_key_enc_type: Option<String>, ) -> Result<(), JacsError>

Source

fn sign_batch(&mut self, messages: &[&str]) -> Result<Vec<String>, JacsError>

Signs multiple strings in a batch operation.

This is more efficient than calling sign_string repeatedly when signing multiple messages because it amortizes the overhead of key decryption and algorithm lookup across all messages.

§Arguments
  • messages - A slice of string references to sign
§Returns

A vector of base64-encoded signatures, one for each input message, in the same order as the input slice.

§Errors

Returns an error if signing any message fails. In case of failure, no signatures are returned (all-or-nothing semantics).

Implementors§