Skip to content

Threshold file encryption (TDH2-style threshold KEM) — nice to have #81

Open

Description

@beanbot-gh

Summary

Nice to have, not planned. This issue records an idea, and the reasoning behind it, so it isn't lost. Pick it up only when a concrete user or use case needs it. Until then it stays deferred.

The idea is threshold file encryption: encrypt a file, or any data of any size, so that any t + 1 of n trustees can open it together and no group of t or fewer can. It would reuse the threshold key and the verified decryption shares from ADR-0053, which merged in #76.

Background: why the existing ElGamal can't do this

ADR-0052's elgamal-jubjub-v1 is exponential ElGamal. A message m is encrypted as [m]·G, and decryption has to search for m with baby-step giant-step. That only works for small numbers. These measurements come from docs/benchmarks/elgamal-jubjub-2026-10-05.md:

Value bound Roughly Decryption search (worst case)
2^32 4.3 billion ~20 ms
2^40 1.1 trillion (≈ 1.1M ADA in lovelace) ~0.8–0.9 s
2^43 (default caps) ≈ 8.8M ADA in lovelace seconds

Encrypting is allowed up to 2^64, but decrypting above about 2^43 is impractical with the defaults. A 128-bit file key is therefore out of reach, and so is a file. Counts, scores, bids and tallies are what this ElGamal is for.

For comparison, single-recipient encryption of data of any size is covered by HPKE (RFC 9180), which ADR-0054 (#77) introduces. What is missing is the threshold case: "any 3 of 5 can open this".

Likely construction (needs its own ADR, R3)

Hybrid encryption with a threshold KEM:

  1. Encrypt the file with a random symmetric key K, using an AEAD such as ChaCha20-Poly1305.
  2. Derive K from a Diffie–Hellman value with the committee's joint key y. Publish A = [r]·G, and derive K from [r]·y.
  3. To open, each trustee publishes a verified decryption share. This is the same D_j = [x_j]·A with a DLEQ proof that ADR-0053 already produces.
  4. Any t + 1 shares combine by Lagrange interpolation to [x]·A = [r]·y, which gives K, which decrypts the file.

Security reference. Plain threshold hashed ElGamal is only CPA-secure. The standard design that also resists chosen-ciphertext attacks in the threshold setting is TDH2: V. Shoup and R. Gennaro, Securing Threshold Cryptosystems against Chosen Ciphertext Attack, EUROCRYPT 1998. The ADR must pin the construction, the KDF and AEAD, the context and label binding, and the share-verification rules. This issue proposes none of them, and per AGENTS.md no cryptography is to be invented here.

On-chain footprint. Files live off-chain, for example on IPFS or S3; a Cardano transaction is at most about 16 KB. On-chain there is only a small header:

  • the encapsulation A (plus TDH2's proof elements);
  • the file hash or content identifier;
  • the binding data, such as session, label and release policy.

Decryption shares, and the decision to release, can be posted on-chain, so the release is auditable.

Why it is "nice to have", not a priority

Where it would add real value over existing tools

It earns its place when on-chain rules decide when the data opens, and trustee misbehaviour must be detectable. Each share is DLEQ-verified, so a cheating trustee is caught.

  • Sealed tenders with full documents, not just bid amounts. They open only after the on-chain deadline, by a quorum.
  • Escrow or dispute evidence. Evidence is posted encrypted, and an arbitration panel (for example 3 of 5) can open it only if a dispute is raised on-chain.
  • Embargoed governance material, such as proposals or audit reports, released when a vote closes or a quorum agrees.
  • Inheritance or a dead-man switch. Keys or instructions are released when the owner stops checking in and the executors agree.

Sketch of milestones (if picked up)

ID Scope
M0 ADR with pinned TDH2 (or an alternative), threat model, binding, invariants. A normative spec plus an independent reference implementation with vectors.
M1 Threshold KEM on top of ADR-0053's ThresholdKeyContext and verified shares. KDF and AEAD from JDK primitives, as in ADR-0054.
M2 File envelope format (off-chain body plus on-chain header), with negative and adversarial tests: wrong label, forged shares, mixed ciphertexts, too few shares.
M3 Example use case, such as a sealed tender on Yaci DevKit, plus docs.

Open questions for the ADR

  • TDH2 or another CCA-secure threshold KEM? Which hash, KDF and AEAD?
  • Labels and context: what binds a ciphertext to its release policy (deadline, script, session)?
  • Should release be enforced only by trustee behaviour, or should an on-chain validator gate the posting of shares?
  • Key lifetime: one DKG per sealed item, or a long-lived committee key?
  • Maturity: experimental, offline class (ADR-0039), with an external audit before any production claim.

Dependencies

Activity

  1. added
    enhancement
    design-adr
    on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    deferdesign-adrenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions