PublicKey

PublicKey[assoc]

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

Details

  • PublicKey objects can be used with functions such as Encrypt, Decrypt and VerifyDigitalSignature.
  • Data encrypted with a particular PublicKey object must be decrypted with a corresponding PrivateKey object.
  • Corresponding pairs of PrivateKey and PublicKey objects can be generated with GenerateAsymmetricKeyPair.
  • PublicKey[]["prop"] can be used to extract properties of the public key.
  • Basic properties for PublicKey include:
  • "Type"type of cryptography
    "PublicByteArray"public key as a byte array
    "PublicHexString"public key as a hex string
    "PublicKeySize"size of public key in bits
  • Possible types of cryptography include "RSA" and "EllipticCurve".
  • Additional properties for "RSA" include:
  • "PublicExponent"public exponent
    "PublicModulus"public modulus
    "Padding"padding mode
  • Additional properties for "EllipticCurve" include:
  • "EllipticCurve"name of elliptic curve (e.g. "sec256k1")
    "PublicCurvePoint"public curve point
    "Compressed"whether the public key is in compressed form
  • PublicKey[]["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 public 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]=

Check if the public key was compressed:

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

Discover all available properties of the public key:

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