fromSecretSeed

Creates a new Stellar KeyPair from a strkey encoded Stellar secret seed.

Security Note: This method accepts a CharArray which allows for secure memory management. After use, the CharArray can be zeroed to remove the secret from memory. This is preferred over String-based methods.

Return

KeyPair with both public and private keys

Parameters

seed

Char array containing strkey encoded Stellar secret seed (S...)

Throws

if the seed format is invalid, has incorrect checksum, wrong version byte, or invalid length


Insecure Creates a new Stellar KeyPair from a strkey encoded Stellar secret seed.

Security Warning

This method is insecure for the following reasons:

  • String values in JVM/Kotlin are immutable and cannot be reliably cleared from memory

  • Strings may be interned, duplicated, or remain in memory even after garbage collection

  • Strings may appear in memory dumps, swap files, or hibernate images

  • If the system is compromised, secret strings can be extracted from memory

Use fromSecretSeed with CharArray instead for better security. CharArray can be explicitly zeroed after use.

Only use this method when:

  • Reading from configuration files that cannot be changed

  • Receiving secrets from external APIs that return strings

  • Prototyping or testing (never in production with real secrets)

Return

KeyPair with both public and private keys

Parameters

seed

The strkey encoded Stellar secret seed (S...)

See also

(CharArray) for secure alternative

Throws

if the seed format is invalid


Creates a new Stellar keypair from a raw 32 byte secret seed.

Security Note: The provided seed array is copied internally. After creating the keypair, you should zero the original seed array if it's no longer needed:

val seed = getSeedFromSomewhere()
val keypair = KeyPair.fromSecretSeed(seed)
seed.fill(0) // Zero the original

Return

KeyPair with both public and private keys

Parameters

seed

The 32 byte secret seed

Throws

if seed is not exactly 32 bytes

if key derivation fails (crypto implementation error)