Skip to main content
ECDSA is recommended for new accounts and applications. It enables setting an EVM Address from Public Key on the account, native compatibility with EVM tooling, and msg.sender resolution in Solidity. See Keys and Signatures for the full comparison.

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, longConstructs an account ID from a public key
Sample Output:

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.
PrivateKey.generate() is deprecated and silently generates an ED25519 key. Use PrivateKey.generateECDSA() for new accounts (recommended) or PrivateKey.generateED25519() if ED25519 is required.
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
Sample Output: