OFFICIAL DEVELOPER DOCUMENTATION

Hardware Security
Developer Guide

Comprehensive technical documentation for building secure applications with hardware wallet integration. Learn USB communication protocols, security architecture, and cryptographic key isolation.

Hardware wallets use HID (Human Interface Device) protocol over USB for secure communication. The APDU (Application Protocol Data Unit) format is used for command/response exchanges.

Communication Flow

Host ApplicationUSB HIDTransport LayerHardwareWalletAPDU CommandAPDU ResponseRaw PacketsRaw PacketsAPDU Command Structure:CLA | INS | P1 | P2 | Lc | Data | LeCLA: Instruction class | INS: Instruction code | P1-P2: Parameters | Lc: Data length | Le: Expected response length

USB Connection Example

// USB HID Transport Implementation
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

async function connectToDevice() {
  try {
    // Request USB device permission
    const transport = await TransportWebUSB.create();
    
    // Send APDU command
    const command = Buffer.from([
      0xE0,        // CLA: Instruction class
      0x01,        // INS: Get version
      0x00,        // P1: Parameter 1
      0x00,        // P2: Parameter 2
      0x00         // Le: Expected response length
    ]);
    
    // Exchange APDU
    const response = await transport.exchange(command);
    
    console.log("Device response:", response.toString('hex'));
    
    return transport;
  } catch (error) {
    console.error("Connection failed:", error);
  }
}

// Listen for device connection
TransportWebUSB.listen({
  next: (event) => {
    if (event.type === "add") {
      console.log("Device connected:", event.descriptor);
    }
  },
  error: (error) => console.error("USB error:", error),
  complete: () => console.log("Listening stopped")
});

HID Packet Size

Maximum packet size: 64 bytes

Fragmentation required for larger payloads

Timeout Configuration

Default timeout: 30 seconds

User confirmation may extend duration

Developer Resources

Download SDKs, documentation, and code examples