GenerateAsymmetricKeyPair
randomly generates a PrivateKey and corresponding PublicKey object for use with public-key cryptographic functions.
GenerateAsymmetricKeyPair[type]
randomly generates private and public keys of the specified type.
GenerateAsymmetricKeyPair[opts]
randomly generates keys using the specified options.
Details and Options
- GenerateAsymmetricKeyPair returns an association of the form <"PrivateKey"…,"PublicKey" … >.
- GenerateAsymmetricKeyPair[] by default uses the "RSA" type, with a system-specific, high-entropy randomness source.
- In GenerateAsymmetricKeyPair[type], the following types can be specified:
-
"RSA" RSA with default parameters "EllipticCurve" elliptic curve secp256k1 "EdwardsCurve" twisted Edwards curve ed25519 "Bitcoin","Ethereum" keys suitable for blockchains Method"curve" named elliptic curve - GenerateAsymmetricKeyPair has the following option:
-
Method Automatic details of key generation method - With the setting Method->assoc, the association assoc gives details of the key generation method to use.
- The following element should be included in the association:
-
"Type" "RSA" type of keys to produce - Possible settings for "Type" are "RSA" , "EllipticCurve" and "EdwardsCurve".
- For "RSA", the following elements can be given in the association:
-
"KeySize" 2048 target size of key in bits "PublicExponent" 65537 public exponent - For "EllipticCurve", the following elements can be given in the association:
-
"CurveName" "secp256k1" elliptic curve to use "Compressed" False whether the public key is in compressed form - For "EdwardsCurve", the following elements can be given in the association:
-
"CurveName" "ed25519" twisted Edwards curve to use - Possible settings for "CurveName" and Methodcurve are listed in $CryptographicEllipticCurveNames.
- "Bitcoin" uses "CurveName""secp256k1" and "Compressed"True.
- "Ethereum" uses "CurveName""secp256k1" and "Compressed"False.
Examples
open allclose allBasic Examples (3)
Scope (6)
Named Methods (4)
Particular Settings (1)
Provide an association with particular settings in the Method option:
Options (6)
Method (6)
Generate a key pair with a 4096-bit key:
Generate a key pair with a public exponent of 17:
Generate a Bitcoin key pair with a compressed public key:
Generate an Ethereum key pair with an uncompressed public key:
Generate a twisted Edwards curve–based key specifying a particular curve name:
Generate an elliptic curve–based key pair using a curve name as method:
Applications (2)
Generate a personal pair of elliptic curve–based keys to sign and verify a message using the Elliptic Curve Digital Signature Algorithm:
Generate a digital signature using your private key:
Verify a digital signature using your public key:
Write simple RSA-based signing and verification functions:
Generate a pair of public and private RSA keys:
Text
Wolfram Research (2015), GenerateAsymmetricKeyPair, Wolfram Language function, https://reference.wolfram.com/language/ref/GenerateAsymmetricKeyPair.html (updated 2020).
CMS
Wolfram Language. 2015. "GenerateAsymmetricKeyPair." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/GenerateAsymmetricKeyPair.html.
APA
Wolfram Language. (2015). GenerateAsymmetricKeyPair. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GenerateAsymmetricKeyPair.html