HDNode
in package
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
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
derive()
Derives a child node at the specified index.
public
derive(int $index) : HDNode
Parameters
- $index : int
-
Child index (automatically converted to hardened).
Tags
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
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
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