Skip to content

test(threshold): verify DKG omission, reconstruction-floor and activation-budget vectors - #773

Merged
samgbafa merged 7 commits into
mainfrom
skgbafa/tc-2226-omission-checker
Nov 29, 2026
Merged

samgbafa merged 7 commits into
mainfrom
skgbafa/tc-2226-omission-checker

Conversation

@samgbafa

Copy link
Copy Markdown
Contributor

Updates the independent TypeScript vector and transcript checker under tinycloud-threshold/vectors/check/ to verify the DKG omission, reconstruction-floor, R6-eligibility, record-ordering and genesis/re-key activation-budget rules in tinycloud-threshold/SPEC.md, and checks vectors/v1/dkg-omission.json (20 cases) alongside the six existing vector documents.

What it changes

  • DKG transcript checker (dkg.ts): Authenticates round records in order just before each is applied, stops after R3 on InsufficientQualified (after the full-transcript size bound), enforces the R6 reconstruction floor (|QUAL| - |reconstructed| >= t → ExcessiveReconstruction) before reading R6 or checking trailing rounds, authenticates R6 before filtering out R6 values from senders lacking a unique envelope in both closed R4 and closed R5 and rejects a trailing round after R6 only after reconstruction.
  • Activation budget (ceremony.ts, certificates.ts): Adds faultBudget(t, n) (1 for 3-of-4, otherwise t - 1) and requires b >= f for genesis and re-key candidates (no predecessor or a previous master key present) after receipt validation and signature checks and before NotEnoughReady.
  • Vector harness and CLI (transcript-common.ts, transcripts.ts, cli.ts, README.md): Adds strict schema validation and verification for vectors/v1/dkg-omission.json (checkOmission) and wires it into bun run vectors / bun run check.
  • Tests (omission.test.ts): Adds unit and CLI tests covering the floor, R6 eligibility filter, check ordering and activation outage budget across genesis, re-key and reshare.

Clean-room provenance

Implemented from tinycloud-threshold/SPEC.md and the committed JSON vector files without consulting the Rust implementation.

Not changed

  • Touches only tinycloud-threshold/vectors/check/** (9 files).
  • No Rust code, no SPEC.md edit, no vector file edit, no Cargo.toml or lockfile change.

Test edits

Four lines in tinycloud-threshold/vectors/check/dkg.test.ts update two existing tests to match the updated SPEC.md S0.3 rules: InsufficientQualified ends the transcript after R3 without reading trailing rounds (lines 126 and 129), and R6 senders must have unique envelopes in closed R4 and closed R5 (lines 164 and 190). No other existing test file changes.

--- a/tinycloud-threshold/vectors/check/dkg.test.ts
+++ b/tinycloud-threshold/vectors/check/dkg.test.ts
@@ -123,10 +123,10 @@ describe('R1–R3 and QUAL', () => {
     const conflictingAndComplained = replace(replace(replace(s, 2, 1, msg(1, complaints([])), msg(1, complaints([2]))), 2, 2, msg(2, complaints([1]))), 2, 3, msg(3, complaints([1])));
     expect(run(s, conflictingAndComplained).disqualified).toEqual([{ member: 1, reason: 'Equivocated', round: 2 }]);
   });
-  test('fewer than t qualified dealers aborts only as the last record', () => {
+  test('fewer than t qualified dealers aborts after R3; later records are not read', () => {
     const alone = s.rounds.map((r, k) => k === 0 ? r.filter(d => d.index === 1) : r);
     expect(code(() => run(s, alone.slice(0, 3)))).toBe('InsufficientQualified');
-    expect(code(() => run(s, alone))).toBe('InvalidRound');
+    expect(code(() => run(s, alone))).toBe('InsufficientQualified');
     expect(code(() => run(s, alone.slice(0, 2)))).toBe('InvalidRound');
   });
   for (const length of [0, 15]) {
@@ -161,7 +161,7 @@ describe('R4–R6 extraction and reconstruction', () => {
   for (const [label, drafts] of faults) {
     test(`${label} R4 is an extraction fault recovered by R6; the dealer stays in QUAL`, () => {
       const faulted = replace(s, 4, 3, ...drafts);
-      const out = run(s, [...faulted, r6(s, [3])]);
+      const out = run(s, [...faulted, r6(s, [3], [1, 2])]);
       expect(out.reconstructed).toEqual([3]);
       expectPublic(out, s, members);
       expect(code(() => run(s, faulted))).toBe('InvalidRound');
@@ -187,7 +187,7 @@ describe('R4–R6 extraction and reconstruction', () => {
     }
   });
   test('fewer than t Pedersen-valid R6 values is InsufficientRecovery', () => {
-    const faulted = replace(s, 4, 3);
+    const faulted = replace(s, 4, 3, msg(3, feldman(s.dealers[2]!.A.slice(0, 1))));
     expect(code(() => run(s, [...faulted, r6(s, [3], [1])]))).toBe('InsufficientRecovery');
     const [x, y] = pair(s.dealers[2]!, 2);
     expect(code(() => run(s, [...faulted, [...r6(s, [3], [1]), msg(2, pairs([[3, x, (y + 1n) % R]]))]]))).toBe('InsufficientRecovery');

Non-blocking review notes

  • transcripts.ts:165-171 (activateCandidate) checks the owner signature inside verifyActivation before comparing activation.body with the recomputed preimage, whereas chain.ts:69-70 compares the body first (InvalidReadiness vs InvalidSignature); every omission activation vector rejects before reaching either check.
  • dkg.test.ts:164 narrows the test's R6 senders to [1, 2] (explicitly excluding the faulted sender whose R4 is absent); omission.test.ts covers ignored ineligible R6 senders directly.
  • activateCandidate (transcripts.ts:165) is exported though used only inside transcripts.ts.

Verification

  • bun install --frozen-lockfile && bun run check: 417/417 tests passed across 22 files, tsc --noEmit clean, all 7 vector documents passed (primitives 18/18, certificate 18/18, DKG 7/7, reshare 5/5, re-key 14/14, chain 8/8, DKG omission 20/20).
  • Rebased mechanically onto 4e511a86 with byte-identical tinycloud-threshold/vectors/check/ tree; tsc --noEmit and bun cli.ts re-verified at head.

Merge effects

Merging to main runs the usual image build, which pushes the main and edge image tags. No deployment runs: deploying stays a manual dispatch.

Details: TC-2226

…tivation budget; check dkg-omission.json

- dkgVerifyTranscript: ExcessiveReconstruction when |QUAL| - reconstructed < t (after R5, before the round count); OwnMessageOmitted for an R6 sender without exactly one R4 and one R5 envelope, before interpolation
- verifyActivation: WithOutageBudget(b) for a genesis or re-key candidate needs b >= f (1 for 3-of-4, otherwise t - 1), else InvalidReadiness
- transcripts.ts/cli.ts: schema and replay of dkg-omission.json (DKG transcripts and verify_activation cases); added to the default document list and README
- omission.test.ts: new tests for each rule and the 3-of-5 chosen-key cases

Details: TC-2226
… rule

- dkg.test.ts:164: `      const out = run(s, [...faulted, r6(s, [3])]);` -> `      const out = run(s, [...faulted, r6(s, [3], [1, 2])]);`
- dkg.test.ts:190: `    const faulted = replace(s, 4, 3);` -> `    const faulted = replace(s, 4, 3, msg(3, feldman(s.dealers[2]!.A.slice(0, 1))));`

No assertion changes. A member whose own R4 is missing or conflicting sends no R6; dealer 3's R4 in the second test is present with the wrong coefficient count, so it stays an extraction fault.

Details: TC-2226
…and R5

- dkgVerifyTranscript: R6 values count only from senders with a unique envelope (after byte-identical deduplication) in both closed R4 and R5; InsufficientRecovery only when fewer than t eligible Pedersen-valid values remain. Replaces the OwnMessageOmitted rejection; QUAL, envelope checks and the post-R5 floor are unchanged
- omission.test.ts: R6-sender tests expect the ineligible R6 to be ignored, with InsufficientRecovery when the eligible values fall below t

Details: TC-2226
- dkgVerifyTranscript: R6 is authenticated only when R5 requires it (missing: InvalidRound), after the floor and before the eligibility filter; an R6 record R5 does not require is not read (InvalidRound); a record after R6 is refused (InvalidRound) only after reconstruction
- verifyActivation: receipts (count <= n, membership, signature length, duplicates, then every signature), then quorum and budget (b > 0, t + b <= n, b >= f), then the ready count, then the activation statement
- omission.test.ts: one test per check order and the ignored-R6 vector pair; CLI edit test names the InsufficientRecovery case

Check order: SPEC S0.3 appendix (R4-R6) and S0.2 activation appendix.

Details: TC-2226
…alified ends the transcript after R3

- dkgVerifyTranscript: each closed round is authenticated just before it is applied (a missing record is InvalidRound); with |QUAL| < t after R3 the result is InsufficientQualified and no record after R3 is read, authenticated or counted
- omission.test.ts: |QUAL| < t with a valid R4, an R4 with a bad closure signature, and a trailing record after R5 all give InsufficientQualified; a bad R3 decides first

Record order: SPEC S0.3 appendix (DkgTranscript).

Details: TC-2226
… record order

- dkg.test.ts:126: `  test('fewer than t qualified dealers aborts only as the last record', () => {` -> `  test('fewer than t qualified dealers aborts after R3; later records are not read', () => {`
- dkg.test.ts:129: `    expect(code(() => run(s, alone))).toBe('InvalidRound');` -> `    expect(code(() => run(s, alone))).toBe('InsufficientQualified');`

Lines 128 and 130 are unchanged. SPEC S0.3 appendix (DkgTranscript): with |QUAL| < t after closed R3 no record after R3 is authenticated or applied; the dkg-omission.json cases *_insufficient_qualified_with_trailing_r4 pin the same order.

Details: TC-2226
- omission.test.ts: with |QUAL| >= t, four records give InvalidRound, and four records with a bad R4 closure signature give InvalidSignature

Details: TC-2226
@samgbafa
samgbafa merged commit cc976be into main Nov 29, 2026
46 of 50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant