Module signing_key

Module signing_key 

Source
Expand description

Module for dealing with signature keys.

See the signature module for more usage.

§generate_keypair

Note: A private key is useless on their own as the public key is also required to sign the data. Therefore, you ned to handle use the full keypair as a private key when you want to sign data.

use std::convert::TryInto;

use devolutions_crypto::signing_key::{generate_signing_keypair, SigningKeyVersion, SigningKeyPair, SigningPublicKey};

let keypair: SigningKeyPair = generate_signing_keypair(SigningKeyVersion::Latest);
let public_key: SigningPublicKey = keypair.get_public_key();

// You can serialize to and from a byte array to store and transfer the keys
let keypair_bytes: Vec<u8> = keypair.into();
let public_bytes: Vec<u8> = public_key.into();

let keypair: SigningKeyPair = (keypair_bytes.as_slice()).try_into().unwrap();
let public_key: SigningPublicKey = (public_bytes.as_slice()).try_into().unwrap();

Re-exports§

pub use super::SigningKeyVersion;

Structs§

SigningKeyPair
A keypair. This should never be sent over an insecure channel or stored unsecurely. To extract the public part of the keypair, use get_public_key()
SigningPublicKey
A public key. This key can be sent in clear on unsecured channels and stored publicly.

Functions§

generate_signing_keypair
Generates a SigningKeyPair to use in a key exchange or to encrypt data.