Trait SigningKey

Source
pub trait SigningKey: Sized {
    // Required methods
    fn decode(sec: &[u8]) -> Option<Self>;
    fn get_logn(&self) -> u32;
    fn to_verifying_key(&self, vrfy_key: &mut [u8]);
    fn sign<T>(
        &mut self,
        rng: &mut T,
        ctx: &DomainContext<'_>,
        id: &HashIdentifier<'_>,
        hv: &[u8],
        sig: &mut [u8],
    )
       where T: CryptoRng + RngCore;
}
Expand description

Signing key handler and temporary buffers.

Signature generation uses relatively large temporary buffers (about 42 or 84 kB, for the two standard degrees), which is why they are part of the SigningKey instance instead of being allocated on the stack. An instance can be used for several successive signature generations. Implementations of this trait are expected to handle automatic zeroization (overwrite of all contained secret values when the object is released).

Required Methods§

Source

fn decode(sec: &[u8]) -> Option<Self>

Create the instance by decoding the signing key from its storage format.

If the source uses a degree not supported by this SigningKey type, or does not have the exact length expected for the degree it uses, or is otherwise invalidly encoded, then this function returns None; otherwise, it returns the new instance.

Source

fn get_logn(&self) -> u32

Get the degree associated with this key.

The degree is returned in a logarithmic scale (logn, value ranges from 2 to 10).

Source

fn to_verifying_key(&self, vrfy_key: &mut [u8])

Encode the public (verifying) key into the provided buffer.

The output buffer must have the exact size of the verifying key.

Source

fn sign<T>( &mut self, rng: &mut T, ctx: &DomainContext<'_>, id: &HashIdentifier<'_>, hv: &[u8], sig: &mut [u8], )
where T: CryptoRng + RngCore,

Generate a signature.

Parameters:

  • rng: a cryptographically secure random source
  • ctx: the domain separation context
  • id: the identifier for the pre-hash function
  • hv: the pre-hashed message (or the message itself, if id is HASH_ID_RAW)
  • sig: the output slice for the generated signature; its size MUST be exactly that expected for the key degree (see signature_size()).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§