# Hidden n_signer in KB2040 Media Controller

## Overview
The goal is to embed the `n_signer` functionality into the existing `keyboard_modules` KB2040 media controller project. The device will normally function as a media controller (volume knob, play/pause, next, prev), but a specific button combination will unlock the `n_signer` mode, allowing the user to enter a mnemonic and sign requests.

## Feasibility: Single USB Connection
**Yes, this is entirely possible over a single USB connection.** 

The RP2040 microcontroller supports USB Composite Devices. By using a USB stack like **TinyUSB** (which is well-supported on the RP2040 via the Pico SDK or Adafruit TinyUSB for Arduino), the device can expose multiple USB interfaces simultaneously:
1.  **HID Interface:** Acts as the standard media controller (Keyboard/Consumer Control).
2.  **Vendor-Specific / WebUSB Interface (or CDC):** Acts as the communication channel for `n_signer` requests.

The host OS will see a single physical USB device with multiple virtual devices attached to it. The media keys will work normally, and the `n_signer` client software can connect to the custom interface concurrently.

## Implementation Plan

### 1. Firmware Environment & USB Stack
*   **Current State:** The `keyboard_modules` project is an Arduino sketch using the standard `<Keyboard.h>`.
*   **Action:** Migrate the USB handling to use **Adafruit TinyUSB** (if staying in Arduino) or port the project to the **Raspberry Pi Pico SDK** (C/C++). TinyUSB is required to easily set up a composite device with both HID and WebUSB/Custom endpoints.

### 2. Integrate n_signer Core
*   **Action:** Bring the core `n_signer` C files (crypto, mnemonic handling, transport framing) into the KB2040 project.
*   **Consideration:** Ensure the cryptographic libraries used by `n_signer` (e.g., secp256k1, hashing) compile and run efficiently on the RP2040 (ARM Cortex-M0+).

### 3. Secret Mode Activation (UI/UX)
*   **Action:** Implement a state machine in the firmware.
    *   **State 1: Media Controller (Default).** Buttons and knob send HID events. Display shows volume.
    *   **State 2: n_signer Mode.** Triggered by a specific chord (e.g., holding Play/Pause + Next for 3 seconds).
*   **Action:** In n_signer mode, repurpose the hardware:
    *   **Knob:** Scroll through letters/words for mnemonic entry, or scroll through request details.
    *   **Buttons:** Select, Cancel, Approve, Reject.
    *   **Display:** Show the `n_signer` UI (mnemonic entry, approval prompts) instead of the volume bar.

### 4. Display Management
*   **Action:** Refactor `display.cpp` to support multiple "views" or "screens". It currently hardcodes the volume UI. It needs to be able to switch to rendering text menus for the signer.

### 5. Host-Side Client
*   **Action:** The `n_signer` client on the host will need to be configured to look for the specific USB VID/PID and interface number of the composite KB2040 device.

## Next Steps
1.  Verify the preferred development environment for the KB2040 (Arduino with Adafruit TinyUSB vs. Pico SDK).
2.  Create a proof-of-concept composite USB device on the KB2040 that exposes both HID and a dummy WebUSB endpoint.
