Stellar PHP SDK API Documentation

HDNode

Hierarchical Deterministic (HD) node for Stellar key derivation.

This class implements BIP-32 style hierarchical deterministic key derivation for Stellar accounts. It supports the SEP-0005 standard for deriving multiple keypairs from a single seed using derivation paths like m/44'/148'/0'.

The implementation follows SLIP-0010 for ed25519 curve key derivation, which is required by SEP-5 for Stellar key generation.

Tags
see
https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0005.md
see
https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
see
https://github.com/satoshilabs/slips/blob/master/slip-0010.md
see
Mnemonic

Table of Contents

Properties

$chainCodeBytes  : string
$privateKeyBytes  : string

Methods

__construct()  : mixed
HDNode constructor.
derive()  : HDNode
Derives a child node at the specified index.
derivePath()  : HDNode
Derives a node following a BIP-32 derivation path.
getChainCodeBytes()  : string
Gets the chain code bytes for this node.
getPrivateKeyBytes()  : string
Gets the private key bytes for this node.
newMasterNode()  : HDNode
Creates a new master HD node from entropy.
parseDerivationPath()  : array<string|int, mixed>
Takes a path like "m/0'/1'" and returns an array of indexes to derive

Properties

$chainCodeBytes

protected string $chainCodeBytes

$privateKeyBytes

protected string $privateKeyBytes

Methods

__construct()

HDNode constructor.

public __construct(string $privateKeyBytes, string $chainCodeBytes) : mixed
Parameters
$privateKeyBytes : string

32 bytes of private key material.

$chainCodeBytes : string

32 bytes of chain code for deriving child keys.

Tags
throws
InvalidArgumentException

If private key or chain code is not 32 bytes.

derive()

Derives a child node at the specified index.

public derive(int $index) : HDNode
Parameters
$index : int

Child index (automatically converted to hardened).

Tags
throws
InvalidArgumentException

If the resulting index is not hardened.

Return values
HDNode

The derived child node.

derivePath()

Derives a node following a BIP-32 derivation path.

public derivePath(string $path) : HDNode
Parameters
$path : string

Derivation path (e.g., "m/44'/148'/0'").

Tags
throws
InvalidArgumentException

If path format is invalid.

Return values
HDNode

The derived node.

getChainCodeBytes()

Gets the chain code bytes for this node.

public getChainCodeBytes() : string
Return values
string

32 bytes of chain code.

getPrivateKeyBytes()

Gets the private key bytes for this node.

public getPrivateKeyBytes() : string
Tags
security

Private key bytes must be handled securely and cleared from memory after use. Never log or expose private keys.

Return values
string

32 bytes of private key material.

newMasterNode()

Creates a new master HD node from entropy.

public static newMasterNode(string $entropy) : HDNode
Parameters
$entropy : string

Binary entropy (typically 64 bytes from mnemonic seed).

Return values
HDNode

A new master node that can derive child keys.

parseDerivationPath()

Takes a path like "m/0'/1'" and returns an array of indexes to derive

protected parseDerivationPath(string $path) : array<string|int, mixed>

Note that since this class assumes all indexes are hardened, the returned array for the above example would be: [0, 1]

Parameters
$path : string
Return values
array<string|int, mixed>

        
On this page

Search results