### Hierarchy

- Key
  - PrivateKey

## Index

### Constructors

- constructor

### Properties

- algorithm
- key
- parameters

### Methods

- computeEcDSASignature
- computeEdDSASignature
- computeHash
- computeSM2Signature
- computeSignature
- decrypt
- encrypt
- getEcDSAPublicKey
- getEdDSAPublicKey
- getPublicKey
- getSM2PublicKey
- isSchemaSupported
- serializeJson
- serializeWIF
- sign
- signAsync
- deserializeWIF
- generateFromMnemonic
- random

## Constructors

### constructor

- new PrivateKey(key: string, algorithm?: KeyType, parameters?: KeyParameters): PrivateKey

- Inherited from Key.constructor

  - Defined in crypto/Key.ts:74

  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

Inherited from Key.algorithm

- Defined in crypto/Key.ts:64

Algorithm used for key generation.

### key

key: string

Inherited from Key.key

- Defined in crypto/Key.ts:74

Key data.

### parameters

parameters: KeyParameters

Inherited from Key.parameters

- Defined in crypto/Key.ts:69

Parameters of the algorithm.

## Methods

### computeEcDSASignature

- computeEcDSASignature(hash: string): string

- - Defined in crypto/PrivateKey.ts:256

  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

- - Defined in crypto/PrivateKey.ts:270

  Computes EdDSA signature of message hash. Curve name is derrived from private key.

  #### Parameters

  - ##### hash: string

    Message hash

  #### Returns string

### computeHash

- computeHash(msg: string, scheme: SignatureScheme): string

- Inherited from Key.computeHash

  - Defined in crypto/Key.ts:108

  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

- - Defined in crypto/PrivateKey.ts:286

  Computes SM2 signature of message hash.

  Only default SM2 ID is supported.

  #### Parameters

  - ##### hash: string

    Message hash

  #### Returns string

### computeSignature

- computeSignature(hash: string, schema: SignatureScheme): string

- - Defined in crypto/PrivateKey.ts:230

  Computes signature of message hash using specified signature schema.

  #### Parameters

  - ##### hash: string

    Message hash

  - ##### schema: SignatureScheme

    Signature schema to use

  #### Returns string

### decrypt

- decrypt(keyphrase: string, address: Address, salt: string, params?: ScryptParams): PrivateKey

- - Defined in crypto/PrivateKey.ts:161

  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

- encrypt(keyphrase: string, address: Address, salt: string, params?: ScryptParams): PrivateKey

- - Defined in crypto/PrivateKey.ts:181

  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

- getEcDSAPublicKey(): PublicKey

- - Defined in crypto/PrivateKey.ts:195

  Derives Public key out of Private key using EcDSA algorithm.

  #### Returns PublicKey

### getEdDSAPublicKey

- getEdDSAPublicKey(): PublicKey

- - Defined in crypto/PrivateKey.ts:206

  Derives Public key out of Private key using EdDSA algorithm.

  #### Returns PublicKey

### getPublicKey

- getPublicKey(): PublicKey

- - Defined in crypto/PrivateKey.ts:140

  Derives Public key out of Private key.

  #### Returns PublicKey

### getSM2PublicKey

- getSM2PublicKey(): PublicKey

- - Defined in crypto/PrivateKey.ts:217

  Derives Public key out of Private key using SM2 algorithm.

  #### Returns PublicKey

### isSchemaSupported

- isSchemaSupported(schema: SignatureScheme): boolean

- Inherited from Key.isSchemaSupported

  - Defined in crypto/Key.ts:141

  Tests if signing schema is compatible with key type.

  #### Parameters

  - ##### schema: SignatureScheme

    Signing schema to use

  #### Returns boolean

### serializeJson

- serializeJson(): JsonKey

- Inherited from Key.serializeJson

  - Defined in crypto/Key.ts:165

  Gets JSON representation of the Key (Public/Private).

  #### Returns JsonKey

### serializeWIF

- serializeWIF(): string

- - Defined in crypto/PrivateKey.ts:299

  Gets Wallet Import Format (WIF) representation of the PrivateKey.

  #### Returns string

### sign

- sign(msg: string, schema?: SignatureScheme, publicKeyId?: undefined | string): Signature

- - Defined in crypto/PrivateKey.ts:101

  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

- signAsync(msg: string, schema?: SignatureScheme, publicKeyId?: undefined | string): Promise<Signature>

- - Defined in crypto/PrivateKey.ts:133

  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

- deserializeWIF(wifkey: string): PrivateKey

- - Defined in crypto/PrivateKey.ts:64

  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

- - Defined in crypto/PrivateKey.ts:75

  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

- random(keyType?: KeyType, parameters?: KeyParameters): PrivateKey

- - Defined in crypto/PrivateKey.ts:46

  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