GenerateAsymmetricKeyPair
✖
GenerateAsymmetricKeyPair
randomly generates a PrivateKey and corresponding PublicKey object for use with public-key cryptographic functions.
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)Summary of the most common use cases
Generate corresponding public and private keys:

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-1hx3su


https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-6z1w1u


https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-20xaef

Alternatively, encrypt with the private key:

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-id5ph0


https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-0wsah8

Generate an elliptic curve key pair using the default curve secp256k1:

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-86tbxj

Generate a twisted Edwards elliptic curve key pair using the default curve ed25519:

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-cqms5e

Scope (6)Survey of the scope of standard use cases
Default Method (1)
Named Methods (4)

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-mijyzi

Generate an elliptic curve key pair using the default curve secp256k1:

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-wbkxee

Generate a twisted Edwards elliptic curve key pair using the default curve ed25519:

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-3gvfs

Generate key pairs compatible with cryptocurrency networks:

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-v5sn4t


https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-il816

Particular Settings (1)
Provide an association with particular settings in the Method option:

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-k9vdc4


https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-fh1vl0

Options (6)Common values & functionality for each option
Method (6)
Generate a key pair with a 4096-bit key:

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-2dliy2

Generate a key pair with a public exponent of 17:

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-cxmocd

Generate a Bitcoin key pair with a compressed public key:

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-g3i65l

Generate an Ethereum key pair with an uncompressed public key:

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-hucp38

Generate a twisted Edwards curve–based key specifying a particular curve name:

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-6wu2a

Generate an elliptic curve–based key pair using a curve name as method:

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-rhgrwp


https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-incklb

Applications (2)Sample problems that can be solved with this function
Generate a personal pair of elliptic curve–based keys to sign and verify a message using the Elliptic Curve Digital Signature Algorithm:

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-d5sr1b

Generate a digital signature using your private key:

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-0xni17

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-h6f4d6

Verify a digital signature using your public key:

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-234bz

Write simple RSA-based signing and verification functions:

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-isk1hv

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-65xzmd
Generate a pair of public and private RSA keys:

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-qbo127


https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-7fxog


https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-thz5mt

Verify that the signature is authentic:

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-d3elvz

Verifying with another expression will fail:

https://wolfram.com/xid/0e2y906xt0t1e4an2jtu-pk0bzd

Possible Issues (2)Common pitfalls and unexpected behavior
Incompatible Private Keys (1)
Wolfram Research (2015), GenerateAsymmetricKeyPair, Wolfram Language function, https://reference.wolfram.com/language/ref/GenerateAsymmetricKeyPair.html (updated 2020).
Text
Wolfram Research (2015), GenerateAsymmetricKeyPair, Wolfram Language function, https://reference.wolfram.com/language/ref/GenerateAsymmetricKeyPair.html (updated 2020).
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.
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
Wolfram Language. (2015). GenerateAsymmetricKeyPair. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GenerateAsymmetricKeyPair.html
BibTeX
@misc{reference.wolfram_2025_generateasymmetrickeypair, author="Wolfram Research", title="{GenerateAsymmetricKeyPair}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/GenerateAsymmetricKeyPair.html}", note=[Accessed: 25-March-2025
]}
BibLaTeX
@online{reference.wolfram_2025_generateasymmetrickeypair, organization={Wolfram Research}, title={GenerateAsymmetricKeyPair}, year={2020}, url={https://reference.wolfram.com/language/ref/GenerateAsymmetricKeyPair.html}, note=[Accessed: 25-March-2025
]}