Returns the signature scheme of this key.
SSH RSA and P-521 keys have no SignatureScheme (the reference defines
none for them) and throw Ssh with the reference's text for their
signatures: Unsupported SSH signature algorithm / Unsupported SSH ECDSA curve.
Returns a human-readable string identifying the key type.
A string like "Ed25519", "Schnorr", "ECDSA", "MLDSA-44", etc.
StaticcodecTagged-CBOR codec; decode also accepts the untagged form.
StaticfromCreates a new Schnorr signing private key from an ECPrivateKey.
The EC private key to use for Schnorr signing
A new Schnorr signing private key
StaticfromCreates a new ECDSA signing private key from an ECPrivateKey.
The EC private key to use for ECDSA signing
A new ECDSA signing private key
StaticfromCreates a new Ed25519 signing private key from an Ed25519PrivateKey.
The Ed25519 private key to use
A new Ed25519 signing private key
StaticfromCreates a new MLDSA signing private key from an MLDSAPrivateKey.
The MLDSA private key to use
A new MLDSA signing private key
StaticfromCreates a new SSH signing private key from an SSHPrivateKey.
The SSH private key to wrap
A new SSH signing private key
StaticrandomA fresh signing key; Ed25519 unless scheme says otherwise. SSH schemes
derive from a PrivateKeyBase instead.
Returns the underlying EC private key if this is a Schnorr or ECDSA key.
The EC private key if this is a Schnorr or ECDSA key, undefined otherwise
Returns the underlying Schnorr private key if this is a Schnorr key.
The EC private key if this is a Schnorr key, undefined otherwise
Returns the underlying ECDSA private key if this is an ECDSA key.
The EC private key if this is an ECDSA key, undefined otherwise
Returns the underlying Ed25519 private key if this is an Ed25519 key.
The Ed25519 private key if this is an Ed25519 key, undefined otherwise
Returns the underlying MLDSA private key if this is an MLDSA key.
The MLDSA private key if this is an MLDSA key, undefined otherwise
Checks if this is a Schnorr signing key.
Checks if this is an ECDSA signing key.
Checks if this is an Ed25519 signing key.
Checks if this is an MLDSA signing key.
Derives the corresponding public key for this private key.
The public key corresponding to this private key
Returns the underlying SSH private key if this is an SSH key.
The SSHPrivateKey if this is an SSH key, undefined otherwise
Checks if this is an SSH signing key.
SigningPrivateKey(<refHexShort>, <inner>)
where <inner> is:
SchnorrPrivateKey(<refHexShort>) / ECDSAPrivateKey(<refHexShort>)
for the secp256k1 variants (the reference formats them inline by tag rather
than delegating to the inner key's Display)SSHPrivateKey(<refHexShort>) for SSH
The previous abbreviated form (SigningPrivateKey(<type>) only) was
a parity drift caught by the E1a summarizer audit.Returns a unique reference to this SigningPrivateKey instance.
The reference is derived from the SHA-256 hash of the tagged CBOR representation, providing a unique, content-addressable identifier.
Signs a message with optional signing options.
Different signature schemes may use the options differently:
The message to sign
Optionaloptions: SigningOptions
Optional signing options
The digital signature
Signs a message using default options.
This is a convenience method that calls signWithOptions with no options.
The message to sign
The digital signature
Verifies a signature against a message using the derived public key.
actually verify; every other scheme returns false. Callers needing
verification for Ed25519 / ECDSA / MLDSA should derive the
public key first via publicKey().verify(...).
The signature to verify
The message that was allegedly signed
true if the signature is a valid Schnorr signature
Signs a message using Schnorr with the provided random number generator.
This method is only valid for Schnorr keys.
The message to sign
The random number generator to use for signature creation
The Schnorr signature
Signs a message using ECDSA.
This method is only valid for ECDSA keys.
The message to sign
The ECDSA signature
Signs a message using Ed25519.
This method is only valid for Ed25519 keys.
The message to sign
The Ed25519 signature
Signs a message using ML-DSA.
This method is only valid for MLDSA keys.
The message to sign
The ML-DSA signature
The CBOR tags this type decodes from; the first one is used to encode.
Returns the untagged CBOR encoding.
Format:
The tagged CBOR form.
As a UR, typed by the first tag's name.
StaticfromReturns the canonical OpenSSH armored PEM for an SSH private key.
Only valid when this SigningPrivateKey wraps an SSHPrivateKey
(i.e. one of the four SignatureScheme.SshXxx variants). Mirrors
the reference implementation's SigningPrivateKey::SSH(key) => key.to_openssh(LineEnding::LF)
usage at signing_private_key.rs:896.
A private key used for creating digital signatures.
Currently supports: