Seed
public final class Seed : Sendable
Represents a Stellar Ed25519 seed used for key generation.
A seed is a 32-byte value used to generate Ed25519 keypairs for Stellar accounts. The seed is the private component from which both the private and public keys are derived.
Seeds can be:
- Generated randomly for new accounts
- Derived from BIP-39 mnemonics for hierarchical deterministic wallets
- Created from existing secret seeds (S-address format)
Security considerations:
- Seeds must be stored securely (use iOS Keychain or equivalent)
- Never expose seeds in logs, network requests, or version control
- Seeds encoded as secret seeds start with ‘S’ and are base32-encoded
-
Creates a seed from the provided bytes.
Throws
Ed25519Error.invalidSeedLength if bytes.count != 32
Declaration
Swift
public init(bytes: [UInt8]) throwsParameters
bytesThe seed bytes (must be exactly 32 bytes)
-
Generates a new random seed using cryptographically secure random number generation.
This creates a 32-byte seed suitable for generating a new Stellar account. The seed is generated using the ed25519C library’s secure random function.
Throws
Ed25519Error.seedGenerationFailed if random generation failsExample:
let seed = try Seed() let keyPair = KeyPair(seed: seed)Declaration
Swift
public convenience init() throws -
Creates a seed from a Stellar secret seed string (S-address).
Decodes a base32-encoded secret seed string (starting with ‘S’) into its binary form. The secret seed is the strkey-encoded representation of a seed, including version byte and checksum for error detection.
Throws
Throws:
- Ed25519Error.invalidSeed if the secret format is invalid
- Ed25519Error.invalidSeedLength if decoded bytes are not 32 bytes
Example:
let seed = try Seed(secret: "SAVZ4FJLGPUXPN4EPLWJBLZW3FZSHH2GQJA6KPB47BQZBZJ7XHVI3T6N")Declaration
Swift
public convenience init(secret: String) throwsParameters
secretA Stellar secret seed string (e.g., “SXXX…”)
-
The raw seed bytes (32 bytes).
Declaration
Swift
public var bytes: [UInt8] { get } -
The Stellar secret seed string (S-address) representation of this seed.
Returns the base32-encoded strkey format with version byte and checksum. This is the format used for storing and transmitting secret seeds.
Security warning: This value grants full control over the associated account. Store it securely and never expose it publicly.
Declaration
Swift
public var secret: String { get }
View on GitHub
Install in Dash