Represents a context-specific cryptographic handle derived from an Identity.

A Handle encapsulates a private key tied to a specific name (context). It provides methods for signing data, verifying signatures, and deriving secondary secrets (like passwords or channel keys) without ever exposing the underlying private key.

Methods

  • Cryptographically signs arbitrary data using the Handle's private key.

    Parameters

    • data: Uint8Array

      The data to be signed, as a Uint8Array.

    Returns Promise<Uint8Array>

    A Promise resolving to the Ed25519 signature as a Uint8Array.

  • Verifies an Ed25519 signature against the provided data and public key.

    Parameters

    • signature: Uint8Array

      The signature to verify (Uint8Array).

    • data: Uint8Array

      The original data that was signed (Uint8Array).

    • publicKey: Uint8Array

      The public key to verify against (Uint8Array).

    Returns Promise<boolean>

    A Promise resolving to true if the signature is valid, false otherwise.

  • Deterministically derives a secret (e.g., a password or API key) for a specific service context. The private key NEVER leaves this class, ensuring maximum security.

    Parameters

    • context: string

      A unique identifier for the service (e.g., 'google', 'github', 'wifi-router').

    • length: number = 16

      Length of the derived raw bytes (default: 16 bytes = ~22 chars base64url).

    Returns string

    A URL-safe base64 string suitable for use as a strong password.

  • Derives a symmetric 256-bit channel key for secure communication between the Identity (controller) and this Handle (device/context).

    Both parties can independently compute this key because:

    1. The Handle possesses its own private key directly.
    2. The Identity can derive the same private key via identity.deriveHandle(name).

    This enables zero-knowledge encrypted channels without key exchange protocols.

    Parameters

    • context: string

      Channel identifier for domain separation (e.g., 'drone-001', 'session-abc'). Both parties MUST use the same context.

    Returns Uint8Array

    A 32-byte Uint8Array suitable for AES-256-GCM encryption.

    // On the drone (Handle side):
    const channelKey = droneHandle.deriveChannelKey('telemetry-v1');
    const encrypted = await encryptAESGCM(telemetry, channelKey);

    // On the control center (Identity side):
    const droneHandle = await centerIdentity.deriveHandle('drone-001');
    const channelKey = droneHandle.deriveChannelKey('telemetry-v1');
    const decrypted = await decryptAESGCM(encrypted, channelKey);