pub struct SigningKey(/* private fields */);Expand description
A DSTU 4145 m=257 private key - see crate::crypto_sign::SigningKey’s own doc comment for
why signing itself needs no RNG.
Implementations§
Source§impl SigningKey
impl SigningKey
Sourcepub fn from_bytes(d: &[u8; 33]) -> Option<Self>
pub fn from_bytes(d: &[u8; 33]) -> Option<Self>
Builds a signing key from a big-endian 33-byte scalar. Returns None if d is zero or
not less than the curve order n - same validation as crypto_sign::SigningKey::from_bytes.
Sourcepub fn generate() -> Result<Self, RandomError>
pub fn generate() -> Result<Self, RandomError>
Generates a fresh signing key from the OS CSPRNG - same rejection-sampling approach as
crypto_sign::SigningKey::generate (docs/TASKS.md T-122), re-derived for this curve’s
own order rather than assumed to carry over: curve257::order()’s top byte is 0x00
(D-185 - unlike m=163’s 0x04), so masking each 33-byte candidate’s top byte down to
zero and its second byte to its low bit (n’s own bit-length is 256, one bit narrower than
the 33-byte/264-bit draw) keeps the rejection rate near 50%, the same target
crypto_sign’s own masking hits for m=163.
§Errors
Returns crate::randombytes::RandomError if the OS CSPRNG fails while drawing a
candidate.
Sourcepub fn to_bytes(&self) -> [u8; 33]
pub fn to_bytes(&self) -> [u8; 33]
Returns d’s big-endian 33-byte encoding - see crypto_sign::SigningKey::to_bytes’s own
doc comment for the caller-zeroizes-it convention this matches.
pub fn verifying_key(&self) -> VerifyingKey
Sourcepub fn sign(&self, message: &[u8]) -> Signature
pub fn sign(&self, message: &[u8]) -> Signature
Signs message - see crypto_sign::SigningKey::sign’s own doc comment.
Sourcepub fn sign_digest(&self, digest: &[u8; 32]) -> Signature
pub fn sign_digest(&self, digest: &[u8; 32]) -> Signature
Signs an already-computed 32-byte Kupyna-256 digest directly - see
crypto_sign::SigningKey::sign_digest’s own doc comment (T-113’s streaming-message note).