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:
-
"CurveName" name of elliptic curve (e.g. "sec256k1") "PrivateMultiplier" private multiplier "PublicCurvePoint" public curve point "Compressed" whether the public key is in compressed form - Possible settings for "CurveName" are listed in $CryptographicEllipticCurveNames.
- PrivateKey[…]["Parameters"] gives all the information contained in the object as an association.
- PrivateKey[…]["Properties"] gives a list of available properties.
Examples
open allclose allBasic Examples (2)
Scope (2)
You can use PrivateKey as a constructor for a valid private key object.
Generate public and private keys:
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:
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:
Text
Wolfram Research (2015), PrivateKey, Wolfram Language function, https://reference.wolfram.com/language/ref/PrivateKey.html (updated 2020).
CMS
Wolfram Language. 2015. "PrivateKey." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/PrivateKey.html.
APA
Wolfram Language. (2015). PrivateKey. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PrivateKey.html