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§
Sourcefn decode(sec: &[u8]) -> Option<Self>
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.
Sourcefn get_logn(&self) -> u32
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).
Sourcefn to_verifying_key(&self, vrfy_key: &mut [u8])
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.
Sourcefn sign<T>(
&mut self,
rng: &mut T,
ctx: &DomainContext<'_>,
id: &HashIdentifier<'_>,
hv: &[u8],
sig: &mut [u8],
)
fn sign<T>( &mut self, rng: &mut T, ctx: &DomainContext<'_>, id: &HashIdentifier<'_>, hv: &[u8], sig: &mut [u8], )
Generate a signature.
Parameters:
rng
: a cryptographically secure random sourcectx
: the domain separation contextid
: the identifier for the pre-hash functionhv
: the pre-hashed message (or the message itself, ifid
isHASH_ID_RAW
)sig
: the output slice for the generated signature; its size MUST be exactly that expected for the key degree (seesignature_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.