@blockchaincommons/components - v1.0.0-beta.4
    Preparing search index...

    Class SigningPrivateKey

    A private key used for creating digital signatures.

    Currently supports:

    • Schnorr private keys (32 bytes, secp256k1) - bare byte string in CBOR
    • ECDSA private keys (32 bytes, secp256k1) - discriminator 1
    • Ed25519 private keys (32 bytes) - discriminator 2
    • MLDSA private keys (post-quantum) - tagged CBOR delegating to MLDSAPrivateKey

    Implements

    Index
    • get scheme(): SignatureScheme

      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 SignatureScheme

    • get keyType(): string

      Returns a human-readable string identifying the key type.

      Returns string

      A string like "Ed25519", "Schnorr", "ECDSA", "MLDSA-44", etc.

    • 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)
      • the inner key's Display for Ed25519 and MLDSA
      • SSHPrivateKey(<refHexShort>) for SSH The previous abbreviated form (SigningPrivateKey(<type>) only) was a parity drift caught by the E1a summarizer audit.

      Returns string

    • Signs a message with optional signing options.

      Different signature schemes may use the options differently:

      • Schnorr: Can accept a custom random number generator via SigningOptions.Schnorr
      • SSH: Requires namespace and hash algorithm via SigningOptions.Ssh
      • Other schemes (ECDSA, Ed25519, MLDSA): Options are ignored

      Parameters

      • message: Uint8Array

        The message to sign

      • Optionaloptions: SigningOptions

        Optional signing options

      Returns Signature

      The digital signature

    • Signs a message using default options.

      This is a convenience method that calls signWithOptions with no options.

      Parameters

      • message: Uint8Array

        The message to sign

      Returns Signature

      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(...).

      Parameters

      • signature: Signature

        The signature to verify

      • message: Uint8Array

        The message that was allegedly signed

      Returns boolean

      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.

      Parameters

      • message: Uint8Array

        The message to sign

      • rng: RandomNumberGenerator

        The random number generator to use for signature creation

      Returns Signature

      The Schnorr signature

      Error if this is not a Schnorr key

    • Signs a message using ECDSA.

      This method is only valid for ECDSA keys.

      Parameters

      • message: Uint8Array

        The message to sign

      Returns Signature

      The ECDSA signature

      Error if this is not an ECDSA key

    • Signs a message using Ed25519.

      This method is only valid for Ed25519 keys.

      Parameters

      • message: Uint8Array

        The message to sign

      Returns Signature

      The Ed25519 signature

      Error if this is not an Ed25519 key

    • Signs a message using ML-DSA.

      This method is only valid for MLDSA keys.

      Parameters

      • message: Uint8Array

        The message to sign

      Returns Signature

      The ML-DSA signature

      Error if this is not an MLDSA key

    • Returns the untagged CBOR encoding.

      Format:

      • Schnorr: h'<32-byte-private-key>' (bare byte string)
      • ECDSA: [1, h'<32-byte-private-key>']
      • Ed25519: [2, h'<32-byte-private-key>']
      • MLDSA: delegates to MLDSAPrivateKey (tagged)

      Returns Cbor

    • Returns 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.

      Returns string