PrivateKey

PrivateKey[assoc]

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

Details

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

Examples

Basic Examples  (2)

Generate public and private keys:

In[1]:=
Click for copyable input
Out[1]=

Encrypt using the public key:

In[2]:=
Click for copyable input
Out[2]=

Decrypt using the private key:

In[3]:=
Click for copyable input
Out[3]=

Generate an elliptic curvebased private key:

In[1]:=
Click for copyable input
Out[1]=

Check the elliptic curve used to create the key pair:

In[2]:=
Click for copyable input
Out[2]=

Discover all available properties of the private key:

In[3]:=
Click for copyable input
Out[3]=
Introduced in 2015
(10.1)
|
Updated in 2019
(12.0)