pub struct IdentityKey { /* private fields */ }
Expand description
Identity Key that allows signing hashes as a given Identity.
This acts as a wrapper for a specific cryptographic private key, and it is only be used for a specific corresponding signature algorithm. The underlying private key may be located in a hardware module or some other private keystore; in this case, it may be impossible to export the key.
§Example
// Make a new temporary key
let key = IdentityKey::new();
// Sign some data with it
let hash = Hash::new(b"I am data, about to be signed");
let signature = key.sign(&hash);
Implementations§
Source§impl IdentityKey
impl IdentityKey
Sourcepub fn from_interface(interface: Arc<dyn SignInterface>) -> IdentityKey
pub fn from_interface(interface: Arc<dyn SignInterface>) -> IdentityKey
Create a new IdentityKey
, given a wrapped object that can implement a
SignInterface.
Sourcepub fn new() -> IdentityKey
pub fn new() -> IdentityKey
Generate a temporary IdentityKey
that exists in program memory.
Sourcepub fn with_rng<R>(csprng: &mut R) -> IdentityKey
pub fn with_rng<R>(csprng: &mut R) -> IdentityKey
Generate a temporary IdentityKey
that exists in program memory, using
the provided cryptographic RNG.
Sourcepub fn with_rng_and_version<R>(
csprng: &mut R,
version: u8,
) -> Result<IdentityKey, CryptoError>
pub fn with_rng_and_version<R>( csprng: &mut R, version: u8, ) -> Result<IdentityKey, CryptoError>
Generate a temporary IdentityKey
that exists in program memory. Uses the specified
version instead of the default, and fails if the version is unsupported.
Sourcepub fn sign(&self, hash: &Hash) -> Signature
pub fn sign(&self, hash: &Hash) -> Signature
Sign a hash. Signing should be fast and always succeed.
Sourcepub fn max_signature_size(&self) -> usize
pub fn max_signature_size(&self) -> usize
The maximum expected size of a signature from this key
Sourcepub fn export_for_lock(&self, lock: &LockId) -> Option<IdentityLockbox>
pub fn export_for_lock(&self, lock: &LockId) -> Option<IdentityLockbox>
Pack this key into a Lockbox
, meant for the recipient specified by lock
. Returns None if
this key cannot be exported.
Sourcepub fn export_for_lock_with_rng<R>(
&self,
csprng: &mut R,
lock: &LockId,
) -> Option<IdentityLockbox>
pub fn export_for_lock_with_rng<R>( &self, csprng: &mut R, lock: &LockId, ) -> Option<IdentityLockbox>
Pack this key into a Lockbox
, meant for the recipient specified by lock
. Returns None if
this key cannot be exported.
Sourcepub fn export_for_stream(&self, stream: &StreamKey) -> Option<IdentityLockbox>
pub fn export_for_stream(&self, stream: &StreamKey) -> Option<IdentityLockbox>
Pack this key into a Lockbox
, meant for the recipient specified by stream
. Returns None
if this key cannot be exported.
Sourcepub fn export_for_stream_with_rng<R>(
&self,
csprng: &mut R,
stream: &StreamKey,
) -> Option<IdentityLockbox>
pub fn export_for_stream_with_rng<R>( &self, csprng: &mut R, stream: &StreamKey, ) -> Option<IdentityLockbox>
Pack this key into a Lockbox
, meant for the recipient specified by stream
. Returns None
if this key cannot be exported.
Trait Implementations§
Source§impl Clone for IdentityKey
impl Clone for IdentityKey
Source§fn clone(&self) -> IdentityKey
fn clone(&self) -> IdentityKey
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more