light

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2026 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package light is the single canonical source of the well-known Lux "light" dev mnemonic and of the deterministic ACCOUNT (wallet) keys derived from it.

Scope: LOCAL network only (primary network ID 1337, EVM chain ID 31337). The mnemonic is public by design — anyone can derive every account key from it, so it MUST NEVER back a production network. RefuseOnProduction is the guard that enforces this.

This package deliberately owns ONLY the deterministic value: the mnemonic and the secp256k1 wallet keys / addresses at the canonical BIP44 path m/44'/9000'/0'/0/i. It has NO staker-cert / NodeID / BLS surface: validator staking identities are intentionally NON-deterministic (random per-node staker keys, so a public seed can never impersonate a node) and live with each node's key material, never here.

Index

Constants

View Source
const LuxCoinType = 9000

LuxCoinType is the BIP44 coin type Lux uses by canonical convention. The full account path is m/44'/9000'/0'/0/i (purpose 44' / coin 9000' / account 0' hardened; change 0 / index i non-hardened) — identical to genesis.LoadKeysFromMnemonic and to every canonical-BIP44 wallet (Lux Wallet, MetaMask, `lux key derive`), so the same seed yields the same addresses everywhere.

View Source
const Mnemonic = "light light light light light light light light light light light energy"

Mnemonic is the well-known public Lux dev seed. Pass it as the value of LUX_MNEMONIC (or LIGHT_MNEMONIC) to bootstrap a local network. It is the SINGLE source of truth for this string across the ecosystem — every other package that needs it should reference light.Mnemonic, never re-declare it.

Variables

This section is empty.

Functions

func IsLight

func IsLight(s string) bool

IsLight reports whether s is exactly the light Mnemonic. Compared in constant time so a timing attacker cannot probe the running config from outside.

func RefuseOnProduction

func RefuseOnProduction(mnemonic string) error

RefuseOnProduction returns a non-nil error when the supplied mnemonic must not be used through the light (local-only) derivation path:

  • empty string → error (no mnemonic set)
  • any non-public seed → error (looks like a real/production mnemonic; luxfi/light is for local dev only, and a production seed must never be fed into a code path that derives from a publicly-known layout)

A recognised public/dev mnemonic (light, BIP-39 vectors, Hardhat, Trezor…) returns nil. This mirrors genesis.RefuseLightMnemonicOnProduction, minus the network-ID coupling: the caller decides WHERE it runs; this decides WHETHER a mnemonic is a safe public/dev value.

Types

type Account

type Account struct {
	Index        int         // BIP44 address index i
	ECPrivateKey []byte      // 32-byte secp256k1 scalar
	EVMAddress   ids.ShortID // 20-byte H160 (C-Chain / EVM)
	LuxAddress   ids.ShortID // 20-byte P/X-Chain address (secp256k1 Address)
}

Account is one deterministic wallet identity derived from the light mnemonic. It carries only account-level material — no staker cert, no NodeID, no BLS — because those are intentionally non-deterministic and out of this package's concern.

func DeriveAccount

func DeriveAccount(i int) (Account, error)

DeriveAccount returns the deterministic wallet account at BIP44 index i (m/44'/9000'/0'/0/i) under the light mnemonic. Byte-for-byte identical to genesis.LoadKeysFromMnemonic's secp256k1 derivation and to any canonical BIP44 wallet on the same seed.

func DeriveAccounts

func DeriveAccounts(n int) ([]Account, error)

DeriveAccounts returns the first n deterministic wallet accounts (indices 0..n-1). It walks the shared m/44'/9000'/0'/0 prefix once.

func (Account) ECPrivateKeyHex

func (a Account) ECPrivateKeyHex() string

ECPrivateKeyHex returns the raw private key as lowercase hex (no 0x).

func (Account) EVMAddressHex

func (a Account) EVMAddressHex() string

EVMAddressHex returns the C-Chain address as 0x-prefixed hex.

func (Account) LuxAddressHex

func (a Account) LuxAddressHex() string

LuxAddressHex returns the P/X-Chain address as 0x-prefixed hex (the raw 20-byte H160 form; use LuxAddress.String() for the cb58 form).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL