Hubert - Distributed Infrastructure for Secure Multiparty Transactions - v1.0.0-alpha.20
    Preparing search index...

    Class MainlineDhtKv

    Mainline DHT-backed key-value store using ARID-based addressing.

    This implementation uses:

    • ARID → ed25519 signing key derivation (deterministic)
    • BEP-44 mutable storage (fixed location based on pubkey)
    • Mainline DHT (BitTorrent DHT) for decentralized storage
    • Write-once semantics (seq=1, put fails if already exists)
    • Maximum value size: 1000 bytes (DHT protocol limit)

    Port of struct MainlineDhtKv from mainline/kv.rs lines 60-64.

    Storage Model

    Uses BEP-44 mutable items where:

    • Public key derived from ARID (deterministic ed25519)
    • Sequence number starts at 1 (write-once)
    • Optional salt for namespace separation
    • Location fixed by pubkey (not content hash)

    Requirements

    No external daemon required - the DHT client runs embedded.

    Size Limits

    The Mainline DHT has a practical limit of ~1KB per value. For larger envelopes, use IpfsKv or HybridKv instead.

    const store = await MainlineDhtKv.create();
    const arid = ARID.new();
    const envelope = Envelope.new("Small message");

    // Put envelope (write-once)
    await store.put(arid, envelope);

    // Get envelope with verbose logging
    const retrieved = await store.get(arid, undefined, true);

    Implements

    Index

    Accessors

    • get isBootstrapped(): boolean

      Check if the DHT is bootstrapped.

      Returns boolean

    Methods

    • Set the maximum value size (default: 1000 bytes).

      Note: Values larger than ~1KB may not be reliably stored in the DHT.

      Port of MainlineDhtKv::with_max_size() from mainline/kv.rs lines 84-87.

      Parameters

      • size: number

      Returns this

    • Set a salt for namespace separation.

      Different salts will create separate namespaces for the same ARID.

      Port of MainlineDhtKv::with_salt() from mainline/kv.rs lines 92-95.

      Parameters

      • salt: Uint8Array

      Returns this

    • Store an envelope at the given ARID.

      Port of KvStore::put() implementation from mainline/kv.rs lines 144-220.

      Parameters

      • arid: ARID
      • envelope: Envelope
      • Optional_ttlSeconds: number
      • Optionalverbose: boolean

      Returns Promise<string>

    • Retrieve an envelope for the given ARID.

      Port of KvStore::get() implementation from mainline/kv.rs lines 223-303.

      Parameters

      • arid: ARID
      • OptionaltimeoutSeconds: number
      • Optionalverbose: boolean

      Returns Promise<Envelope | null>

    • Check if an envelope exists at the given ARID.

      Port of KvStore::exists() implementation from mainline/kv.rs lines 306-314.

      Parameters

      • arid: ARID

      Returns Promise<boolean>

    • Destroy the DHT client and release resources.

      Returns Promise<void>