Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Key
    • PrivateKey

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 PrivateKey

Properties

algorithm

algorithm: KeyType

Algorithm used for key generation.

key

key: string

Key data.

parameters

parameters: KeyParameters

Parameters of the algorithm.

Methods

computeEcDSASignature

  • computeEcDSASignature(hash: string): string
  • Computes EcDSA signature of message hash. Curve name is derrived from private key.

    Parameters

    • hash: string

      Message hash

    Returns string

computeEdDSASignature

  • computeEdDSASignature(hash: string): string
  • Computes EdDSA signature of message hash. Curve name is derrived from private key.

    Parameters

    • hash: string

      Message hash

    Returns string

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

computeSM2Signature

  • computeSM2Signature(hash: string): string
  • Computes SM2 signature of message hash.

    Only default SM2 ID is supported.

    Parameters

    • hash: string

      Message hash

    Returns string

computeSignature

  • Computes signature of message hash using specified signature schema.

    Parameters

    • hash: string

      Message hash

    • schema: SignatureScheme

      Signature schema to use

    Returns string

decrypt

  • Decrypts encrypted private key with supplied password.

    Parameters

    • keyphrase: string

      Password to decrypt with

    • address: Address

      For aad in decryption

    • salt: string
    • Optional params: ScryptParams

      Optional Scrypt params

    Returns PrivateKey

encrypt

  • Encrypts private key with supplied password.

    Parameters

    • keyphrase: string

      Password to encrypt with

    • address: Address

      For aad in encryption

    • salt: string

      16 secure random bytes

    • Optional params: ScryptParams

      Optional Scrypt params

    Returns PrivateKey

getEcDSAPublicKey

getEdDSAPublicKey

getPublicKey

getSM2PublicKey

isSchemaSupported

serializeJson

serializeWIF

  • serializeWIF(): string

sign

  • Signs the data with supplied private key using signature schema.

    If the signature schema is not provided, the default schema for this key type is used.

    This method is not suitable, if external keys (Ledger, TPM, ...) support is required.

    Parameters

    • msg: string

      Hex encoded input data

    • Optional schema: SignatureScheme

      Signing schema to use

    • Optional publicKeyId: undefined | string

      Id of public key

    Returns Signature

signAsync

  • Asynchroniously signs the data with supplied private key using signature schema.

    If the signature schema is not provided, the default schema for this key type is used.

    This method is suitable, if external keys (Ledger, TPM, ...) support is required.

    Parameters

    • msg: string

      Hex encoded input data

    • Optional schema: SignatureScheme

      Signing schema to use

    • Optional publicKeyId: undefined | string

      Id of public key

    Returns Promise<Signature>

Static deserializeWIF

  • Creates PrivateKey from Wallet Import Format (WIF) representation.

    Parameters

    • wifkey: string

      WIF private key representation

    Returns PrivateKey

Static generateFromMnemonic

  • generateFromMnemonic(mnemonic: string, derivePath?: string): PrivateKey
  • Creates PrivateKey from mnemonic according to BIP39 protocol.

    Parameters

    • mnemonic: string

      Space separated list of words

    • Default value derivePath: string = ONT_BIP44_PATH

    Returns PrivateKey

Static random

  • Generates random Private key using supplied Key type and parameters.

    If no Key type or parameters is supplied, default SDK key type with default parameters will be used.

    Parameters

    • Optional keyType: KeyType

      The key type

    • Optional parameters: KeyParameters

      The parameters for the key type

    Returns PrivateKey

Generated using TypeDoc