Options
All
  • Public
  • Public/Protected
  • All
Menu

Class to manage the public key with some userful functions.

Hierarchy

  • Key
    • PublicKey

Index

Constructors

constructor

  • Creates Key.

    If no algorithm or parameters are specified, default values will be used. This is strongly discurraged, because it will forbid using other Key types. Therefore use it only for testing.

    Parameters

    • key: string

      Hex encoded key value

    • Optional algorithm: KeyType

      Key type

    • Optional parameters: KeyParameters

      Parameters of the key type

    Returns PublicKey

Properties

algorithm

algorithm: KeyType

Algorithm used for key generation.

key

key: string

Key data.

parameters

parameters: KeyParameters

Parameters of the algorithm.

Methods

computeHash

  • Computes hash of message using hashing function of signature schema.

    Parameters

    • msg: string

      Hex encoded input data

    • scheme: SignatureScheme

      Signing schema to use

    Returns string

isSchemaSupported

serializeHex

  • serializeHex(): string
  • Serializes public key to Hex representation.

    Length definition is not included.

    Returns string

serializeJson

verify

  • verify(msg: string, signature: Signature): boolean
  • Verifies if the signature was created with private key corresponding to supplied public key and was not tampered with using signature schema.

    Parameters

    • msg: string

      Hex encoded input data

    • signature: Signature

      Signature object

    Returns boolean

verifyEcDSASignature

  • verifyEcDSASignature(hash: string, signature: string): boolean
  • Verifies EcDSA signature of message hash. Curve name is derrived from private key.

    Parameters

    • hash: string

      Message hash

    • signature: string

      Hex encoded signature

    Returns boolean

verifyEdDSASignature

  • verifyEdDSASignature(hash: string, signature: string): boolean
  • Verifies EdDSA signature of message hash. Curve name is derrived from private key.

    Parameters

    • hash: string

      Message hash

    • signature: string

      Hex encoded signature

    Returns boolean

verifySM2Signature

  • verifySM2Signature(hash: string, signature: string): boolean
  • Verifies SM2 signature of message hash.

    Only default SM2 ID is supported.

    Parameters

    • hash: string

      Message hash

    • signature: string

      Hex encoded signature

    Returns boolean

verifySignature

  • verifySignature(hash: string, signature: string, schema: SignatureScheme): boolean
  • For internal use.

    Parameters

    • hash: string

      Message hash

    • signature: string

      Hex encoded signature

    • schema: SignatureScheme

      Signature scheme to use

    Returns boolean

Static deserializeHex

Generated using TypeDoc