Lux Docs

Lux HSM

Unified hardware security module for blockchain infrastructure

Lux HSM (github.com/luxfi/hsm) provides a single Go interface (Signer) for signing and verification across sixteen backend providers — cloud KMS/HSM, networked and USB HSMs, hardware-wallet secure elements, air-gapped devices, banking key-blocks, and post-quantum ML-DSA. One factory, one interface, many backends. All secrets are managed through Lux KMS — never stored as plaintext.

Core Interfaces

type Signer interface {
    Sign(ctx context.Context, keyID string, message []byte) ([]byte, error)
    Verify(ctx context.Context, keyID string, message, signature []byte) (bool, error)
    Provider() string
}

type PasswordProvider interface {
    GetPassword(ctx context.Context, keyID string) (string, error)
}

Signing Providers

All sixteen are registered in one factory — hsm.NewSigner(provider, config).

Cloud KMS / HSM

ProviderBackendAlgorithm
awsAWS KMS / CloudHSMECDSA P-256 (SigV4, no SDK)
gcpGoogle Cloud KMSEC_SIGN_P256_SHA256
azureAzure Key Vault / Managed HSMES256
kmipAny KMIP 1.x HSM (Thales, Entrust, …)KMIP Sign (requires cgo)

Networked / USB HSM

ProviderBackendNotes
pkcs11Any PKCS#11 token (Thales Luna, SoftHSM, …)Universal HSM standard (requires cgo)
yubihsmYubiHSM 2aliases yubico, yubi
nitrokeyNitrokey HSMOpenPGP/PKCS#11 secure element
zymbitZymbit SCM / HSM6Edge/IoT; native threshold (ThresholdHSM)

Hardware-wallet secure elements

ProviderDevice
ledgerLedger (Nano S/X/Stax)
trezorTrezor
coldcardColdcard
keystoneKeystone (air-gap QR)
gridplus / latticeGridPlus Lattice1 (SafeCard)
ngraveNGRAVE ZERO
foundationFoundation Passport

Software, banking & post-quantum

ProviderAlgorithmUse
mldsa / pq / post-quantumML-DSA-44 / 65 / 87 (FIPS 204)Post-quantum signing
tr31ANSI X9.143 / TR-31 key blocksBanking / payments key wrapping
local / ""ECDSA P-256 in-memoryDevelopment and testing only

FIPS posture. hsm.RequireFIPSProvider admits only the FIPS-validated backends: aws, gcp, azure, yubihsm, pkcs11, kmip. Wire it before constructing a signer to fail closed on a non-FIPS provider. local is development only — never production.

Build notes: pkcs11 and kmip link a native library and require cgo (a no-cgo build falls back to a stub that refuses to sign). The GridPlus Lattice1 Connect-API path is partial — track its status before production use.

Password Providers

ProviderSourceUse Case
awsAWS KMS DecryptZapDB password from KMS
gcpGCP Cloud KMS DecryptZapDB password from KMS
azureAzure Key Vault unwrapKeyZapDB password from Key Vault
envEnvironment variableDevelopment only (never production)
fileFile on diskK8s mounted secrets (via KMS operator)

Quick Example

package main

import (
    "context"
    "fmt"
    "github.com/luxfi/hsm"
)

func main() {
    // Create a signer
    signer, _ := hsm.NewSigner("aws", map[string]string{
        "region": "us-east-1",
    })

    ctx := context.Background()
    keyID := "arn:aws:kms:us-east-1:123456789:key/my-signing-key"

    // Sign
    sig, _ := signer.Sign(ctx, keyID, []byte("hello world"))

    // Verify
    ok, _ := signer.Verify(ctx, keyID, []byte("hello world"), sig)
    fmt.Println("Valid:", ok) // true
}

Architecture

┌─────────────────────────────────────────────┐
│                  Manager                     │
│  ┌──────────────────┐  ┌──────────────────┐ │
│  │  PasswordProvider │  │     Signer       │ │
│  └────────┬─────────┘  └────────┬─────────┘ │
│           │                     │            │
│  ┌────────▼─────────────────────▼─────────┐ │
│  │         Factory (NewSigner / etc)       │ │
│  └────┬───────────┬───────────┬───────────┘ │
│       │           │           │              │
│   Cloud KMS   Networked/    Hardware-wallet  │
│   AWS·GCP·    USB HSM       secure elements  │
│   Azure·KMIP  PKCS11·Yubi·  Ledger·Trezor·   │
│               Nitro·Zymbit  Coldcard·...     │
│                                              │
│            + mldsa (PQ) · tr31 · local       │
└─────────────────────────────────────────────┘

On this page