XRPL Keypairs Codec

Low-level functions for creating and using cryptographic keys with the XRP Ledger.

exception xrpl.core.keypairs.XRPLKeypairsException

Bases: XRPLException

General XRPL Keypair Codec Exception.

xrpl.core.keypairs.derive_classic_address(public_key: str) str

Derive the XRP Ledger classic address for a given public key. See Address Derivation for more information.


public_key – The public key to derive the address from, as hexadecimal.


The classic address corresponding to the given public key.

xrpl.core.keypairs.derive_keypair(seed: str, validator: bool = False) Tuple[str, str]

Derive the public and private keys from a given seed value.

  • seed – Seed to derive the key pair from. Use generate_seed() to generate an appropriate value.

  • validator – Whether the keypair is a validator keypair.


A (public key, private key) pair derived from the given seed.


XRPLKeypairsException – If the derived keypair did not generate a verifiable signature.

xrpl.core.keypairs.generate_seed(entropy: Optional[str] = None, algorithm: CryptoAlgorithm = CryptoAlgorithm.ED25519) str

Generate a seed value that cryptographic keys can be derived from.

  • entropy – Must be at least addresscodec.SEED_LENGTH bytes long and will be truncated to that length

  • algorithm – CryptoAlgorithm to use for seed generation. The default is CryptoAlgorithm.ED25519.


A seed value that can be used to derive a key pair with the given

cryptographic algorithm.

xrpl.core.keypairs.is_valid_message(message: bytes, signature: bytes, public_key: str) bool

Verifies the signature on a given message.

  • message – The message to validate.

  • signature – The signature of the message.

  • public_key – The public key to use to verify the message and signature.


Whether the message is valid for the given signature and public key.

xrpl.core.keypairs.sign(message: bytes, private_key: str) str

Sign a message using a given private key.

  • message – The message to sign, as bytes.

  • private_key – The private key to use to sign the message.


Signed message, as hexadecimal.