Ed25519Crypto

interface Ed25519Crypto

Platform-specific Ed25519 cryptographic operations.

Production-Ready Implementations

All implementations use audited, battle-tested cryptographic libraries:

JVM

  • Library: BouncyCastle (org.bouncycastle:bcprov-jdk18on)

  • Algorithm: Ed25519 via Ed25519Signer, Ed25519PrivateKeyParameters

  • Security: RFC 8032 compliant, constant-time operations

  • Provider: Registered as JCA security provider

iOS/macOS (Native)

  • Library: libsodium (via C interop)

  • Algorithm: Ed25519 via crypto_sign_* functions

  • Security: Audited, constant-time, memory-safe

  • Random: randombytes_buf() using system CSPRNG

  • Why libsodium over CryptoKit:

  • Direct C interop (no Swift bridge needed)

  • Matches Stellar's exact key format (raw 32-byte seeds)

  • Cross-platform (same code for iOS, macOS, Linux)

  • Used by stellar-core reference implementation

  • Industry standard (Signal, Tor, etc.)

JavaScript (Browser & Node.js)

  • Primary: Web Crypto API (Chrome 113+, Firefox 120+, Safari 17+)

  • Fallback: libsodium-wrappers (WebAssembly, universal compatibility)

  • Strategy: Automatic detection and graceful fallback

  • Security: libsodium.js is the same audited C library compiled to WASM

  • Compatibility: Works in all modern browsers and Node.js

  • Why libsodium.js over TweetNaCl:

  • More features (crypto_sign_seed_keypair for key derivation)

  • Better performance (WebAssembly vs pure JS)

  • Same library as native implementation

  • Actively maintained

See also

Properties

Link copied to clipboard
abstract val libraryName: String

Returns the name of the cryptographic library being used.

Functions

Link copied to clipboard
abstract suspend fun derivePublicKey(privateKey: ByteArray): ByteArray

Derives the public key from a private key.

Link copied to clipboard
abstract suspend fun generatePrivateKey(): ByteArray

Generates a new random Ed25519 private key (32 bytes).

Link copied to clipboard
abstract suspend fun sign(data: ByteArray, privateKey: ByteArray): ByteArray

Signs data using Ed25519.

Link copied to clipboard
abstract suspend fun verify(data: ByteArray, signature: ByteArray, publicKey: ByteArray): Boolean

Verifies an Ed25519 signature.