represents the private part of a key pair for a public-key cryptographic system.


  • PrivateKey objects can be used with functions such as Encrypt, Decrypt and GenerateDigitalSignature.
  • For encryption, data can only be decrypted with a particular PrivateKey object if it was encrypted with the corresponding PublicKey object.
  • Corresponding pairs of PrivateKey and PublicKey objects can be generated with GenerateAsymmetricKeyPair.
  • PrivateKey[]["prop"] can be used to extract properties of the private key.
  • Basic properties for a PrivateKey include:
  • "Type"type of cryptography
    "PrivateByteArray"private key as a byte array
    "PublicByteArray"public key as a byte array
    "PrivateHexString"private key as a hex string
    "PublicHexString"public key as a hex string
    "PrivateKeySize"size of private key in bits
    "PublicKeySize"size of public key in bits
  • Possible types of cryptography include "RSA" and "EllipticCurve".
  • Additional properties for "RSA" include:
  • "PrivateExponent"private exponent
    "PublicExponent"public exponent
    "PublicModulus"public modulus
    "Padding"padding mode
  • Additional properties for "EllipticCurve" include:
  • "EllipticCurve"name of elliptic curve (e.g. "sec256k1")
    "PrivateMultiplier"private multiplier
    "PublicCurvePoint"public curve point
    "Compressed"whether the public key is in compressed form
  • PrivateKey[]["Properties"] gives a list of available properties.


open allclose all

Basic Examples  (2)

Generate public and private keys:

Encrypt using the public key:

Decrypt using the private key:

Generate an elliptic curvebased private key:

Check the elliptic curve used to create the key pair:

Discover all available properties of the private key:

Scope  (2)

You can use PrivateKey as a constructor for a valid private key object.

Generate public and private keys:

Obtain the private key:

Construct a valid private key object from the pre-generated values:

Test whether it matches the original key:

Construct a valid PrivateKey object from an existing key provided as a hex string:

Equivalently, use the key's integer representation:

The object representation will be the same in both cases:

Properties & Relations  (2)

PrivateKey objects created by GenerateAsymmetricKeyPair contain a complete set of properties for the key:

It is not necessary to provide all properties to reconstruct a valid private key object. For an elliptic curve, it is sufficient to specify only the private multiplier:

Verify that the keys are identical:

Alternatively, use a hex string representation of the private multiplier:

Verify that all keys are identical:

Use a ByteArray representation:

Verify that all keys are identical:

To reconstruct a PrivateKey object for RSA, provide both the private exponent and the public modulus:

Recreate the same object as initially obtained from GenerateAsymmetricKeyPair:

Verify that both keys are identical:

Introduced in 2015
Updated in 2019