random

suspend fun random(): KeyPair

Generates a random Stellar keypair using cryptographically secure random number generation.

Implementation Details

JVM

Uses java.security.SecureRandom via BouncyCastle's Ed25519PrivateKeyParameters

Native (iOS/macOS)

Uses randombytes_buf() from libsodium, which uses:

  • macOS: arc4random_buf() backed by the system's CSPRNG

  • iOS: Same as macOS

All implementations provide cryptographically secure randomness suitable for generating private keys.

Return

a random Stellar keypair with both public and private keys

Throws

if random generation or key derivation fails