Skip to main content

ED25519

Create a new ED25519 key pair used to sign transactions and queries on the Hedera network. The private key is kept confidential and is used to sign transactions that modify the state of an account, topic, token, smart contract, or file entity on the network. The public key can be shared with other users on the network.
MethodTypeDescription
PrivateKey.generateED25519()PrivateKeyGenerates an Ed25519 private key
PrivateKey.generateED25519().getPublicKey()PublicKeyDerive a public key from this Ed25519 private key
PrivateKey.generateED25519().publicKey()PublicKeyDerive a public key from this Ed25519 private key
PrivateKey.generateED25519().publicKey().toAccountId(<shard>,<realm>)long, longContruct an alias account ID from a alias public key address
[DEPRECATED]PrivateKey.generate()PrivateKeyGenerates an Ed25519 private key
PrivateKey privateKey = PrivateKey.generateED25519();
PublicKey publicKey = privateKey.getPublicKey();

System.out.println("private key = " + privateKey);
System.out.println("public key = " + publicKey);
Sample Output:
private key = 302e020100300506032b657004220420b9c3ebac81a72aafa5490cc78111643d016d311e60869436fbb91c73307ed35a
public key = 302a300506032b65700321001a5a62bb9f35990d3fea1a5bb7ef6f1df0a297697adef1e04510c9d4ecc5db3f

ECDSA (secp256k1_)

Create a new ECDSA (secp256k1) key pair used to sign transactions and queries on a Hedera network. The private key is kept confidential and is used to sign transactions that modify the state of an account, topic, token, smart contract, or file entity on the network. The public key can be shared with other users on the network.
MethodTypeDescription
PrivateKey.generateECDSA()PrivateKeyGenerates an ECSDA private key
PrivateKey.generateECDSA().getPublicKey()PublicKeyDerive a public key from this ECDSA private key
PrivateKey.generateECDSA().publicKey()PublicKeyDerive a public key from this ECDSA private key
PrivateKey.generateECDSA().publicKey().toAccountId(<shard>, <realm>)long, longContructs an account ID from an account alias public key
PrivateKey privateKey = PrivateKey.generateECDSA();
PublicKey publicKey = privateKey.getPublicKey();

System.out.println("private key = " + privateKey);
System.out.println("public key = " + publicKey);
Sample Output: