({{, (RefLink[PrivateKey, paclet:ref/PrivateKey])[assoc]
represents the private part of a key pair for a public-key cryptographic system.}})

OpenersNotesSection(Spacer1)Details

(RefLink[PrivateKey, paclet:ref/PrivateKey]) objects can be used with functions such as (RefLink[Encrypt, paclet:ref/Encrypt]), (RefLink[Decrypt, paclet:ref/Decrypt]) and (RefLink[GenerateDigitalSignature, paclet:ref/GenerateDigitalSignature]).

For encryption, data can only be decrypted with a particular (RefLink[PrivateKey, paclet:ref/PrivateKey]) object if it was encrypted with the corresponding (RefLink[PublicKey, paclet:ref/PublicKey]) object.

Corresponding pairs of (RefLink[PrivateKey, paclet:ref/PrivateKey]) and (RefLink[PublicKey, paclet:ref/PublicKey]) objects can be generated with (RefLink[GenerateAsymmetricKeyPair, paclet:ref/GenerateAsymmetricKeyPair]).

(RefLink[PrivateKey, paclet:ref/PrivateKey])[…]["prop"] can be used to extract properties of the private key.

Basic properties for a (RefLink[PrivateKey, paclet:ref/PrivateKey]) include:

Possible types of cryptography include "RSA" and "EllipticCurve".

Additional properties for "RSA" include:

Additional properties for "EllipticCurve" include:

(RefLink[PrivateKey, paclet:ref/PrivateKey])[…]["Properties"] gives a list of available properties.

OpenersPrimaryExamplesSection(Spacer1)Examples  (2)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Generate public and private keys:

keys=GenerateAsymmetricKeyPair[]

Encrypt using the public key:

Encrypt[keys["PublicKey"],"Now is the time..."]

Decrypt using the private key:

Decrypt[keys["PrivateKey"],%]

Generate an elliptic curve–based private key:

keys=GenerateAsymmetricKeyPair["EllipticCurve"]

Check the elliptic curve used to create the key pair:

keys["PrivateKey"]["CurveName"]

Discover all available properties of the private key:

keys["PrivateKey"]["Properties"]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[PublicKey, paclet:ref/PublicKey])  ▪  (RefLink[GenerateAsymmetricKeyPair, paclet:ref/GenerateAsymmetricKeyPair])  ▪  (RefLink[Encrypt, paclet:ref/Encrypt])  ▪  (RefLink[Decrypt, paclet:ref/Decrypt])  ▪  (RefLink[GenerateDigitalSignature, paclet:ref/GenerateDigitalSignature])  ▪  (RefLink[VerifyDigitalSignature, paclet:ref/VerifyDigitalSignature])  ▪  (RefLink[BlockchainKeyEncode, paclet:ref/BlockchainKeyEncode])  ▪  (RefLink[EulerPhi, paclet:ref/EulerPhi])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Cryptography, paclet:guide/Cryptography])}, {▪(RefLinkPlain[Cryptographic Number Theory, paclet:guide/CryptographicNumberTheory])}, {▪(RefLinkPlain[Working with Blockchains, paclet:guide/Blockchain])}})}})