Documentation
¶
Overview ¶
Package keys provides key derivation and management utilities for LUX.
Index ¶
- Constants
- func DeriveKeyFromMnemonic(mnemonic string, accountIndex uint32) ([]byte, error)
- func DeriveKeyFromSeed(seed []byte, accountIndex uint32) ([]byte, error)
- func GenerateNodeID() (ids.NodeID, []byte, []byte, error)
- func LoadKey(keyPath string) ([]byte, error)
- func LoadKeyFromEnv() ([]byte, error)
- func LoadKeyFromFile(path string) ([]byte, error)
- func MustNewKeychain(keyBytes []byte) *secp256k1fx.Keychain
- func NewKeychain(keyBytes []byte) (*secp256k1fx.Keychain, error)
- func ToPrivateKey(keyBytes []byte) (*secp256k1.PrivateKey, error)
- func ValidatorBundlesToCAddresses(bundles []ValidatorBundle) []common.Address
- func ValidatorBundlesToNodeIDs(bundles []ValidatorBundle) []ids.NodeID
- type ValidatorBundle
Constants ¶
const ( // LUXCoinType is the BIP-44 coin type for LUX (9000') LUXCoinType = 9000 // DefaultDerivationPath is the standard BIP-44 path for LUX: m/44'/9000'/0'/0/0 DefaultDerivationPath = "m/44'/9000'/0'/0/0" )
Variables ¶
This section is empty.
Functions ¶
func DeriveKeyFromMnemonic ¶
DeriveKeyFromMnemonic derives a private key from a BIP-39 mnemonic using BIP-44 path. Default path: m/44'/9000'/0'/0/0
func DeriveKeyFromSeed ¶
DeriveKeyFromSeed derives a private key from a BIP-39 seed using BIP-44 path. Path: m/44'/9000'/0'/0/{accountIndex}
func GenerateNodeID ¶
GenerateNodeID creates a new random NodeID (for non-deterministic use cases)
func LoadKey ¶
LoadKey loads a key from file, environment, or returns an error. Priority: 1) keyPath if non-empty, 2) LUX_PRIVATE_KEY env, 3) LUX_MNEMONIC env
func LoadKeyFromEnv ¶
LoadKeyFromEnv loads a key from environment variables. Priority: 1) LUX_PRIVATE_KEY (hex), 2) LUX_MNEMONIC (24 words)
func LoadKeyFromFile ¶
LoadKeyFromFile reads a hex-encoded private key from a file.
func MustNewKeychain ¶
func MustNewKeychain(keyBytes []byte) *secp256k1fx.Keychain
MustNewKeychain creates a secp256k1fx.Keychain from raw key bytes, panics on error.
func NewKeychain ¶
func NewKeychain(keyBytes []byte) (*secp256k1fx.Keychain, error)
NewKeychain creates a secp256k1fx.Keychain from raw key bytes.
func ToPrivateKey ¶
func ToPrivateKey(keyBytes []byte) (*secp256k1.PrivateKey, error)
ToPrivateKey converts raw key bytes to a secp256k1 private key.
func ValidatorBundlesToCAddresses ¶
func ValidatorBundlesToCAddresses(bundles []ValidatorBundle) []common.Address
ValidatorBundlesToCAddresses extracts C-chain addresses from bundles
func ValidatorBundlesToNodeIDs ¶
func ValidatorBundlesToNodeIDs(bundles []ValidatorBundle) []ids.NodeID
ValidatorBundlesToNodeIDs extracts NodeIDs from a slice of bundles
Types ¶
type ValidatorBundle ¶
type ValidatorBundle struct {
// Index is the BIP-44 address index used to derive this bundle
Index uint32
// NodeID is the unique identifier for this validator node
NodeID ids.NodeID
// Staking TLS certificate and key (PEM-encoded)
StakingCertPEM []byte
StakingKeyPEM []byte
// BLS key for validator signatures (raw 32-byte secret key)
BlsSecretKey []byte
// BLS public key (48 bytes, derived from BlsSecretKey)
BlsPublicKey []byte
// SECP256K1 private key (raw 32 bytes) for P/X/C chain transactions
SecpPrivKey []byte
// Addresses on different chains (derived from SecpPrivKey)
PAddress string // Bech32 P-chain address
XAddress string // Bech32 X-chain address
CAddress string // Hex C-chain address (0x...)
}
ValidatorBundle contains all cryptographic materials for a validator node. This is a pure data structure with no key management logic - the CLI handles storage, environment reads, and interactive selection.
func DeriveValidatorBundle ¶
func DeriveValidatorBundle(mnemonic string, index uint32, hrp string) (ValidatorBundle, error)
DeriveValidatorBundle derives a single validator bundle from a mnemonic at given index.
func DeriveValidatorBundles ¶
func DeriveValidatorBundles(mnemonic string, n int, hrp string) ([]ValidatorBundle, error)
DeriveValidatorBundles derives n validator bundles from a BIP-39 mnemonic. Each bundle contains all cryptographic materials needed to run a validator: - Staking TLS certificate and private key - BLS signing key - SECP256K1 key for transactions - Derived addresses for P/X/C chains
This is a pure function - it takes mnemonic, returns bundles, with no side effects. Key storage and management is the responsibility of the CLI, not the SDK.