Skip to content

fix(service): generate and seal keys only after the round is verified on-chain - #98

Merged
0xHansLee merged 1 commit into
mainfrom
fix/keygen-after-round-verification
Aug 7, 2026
Merged

fix(service): generate and seal keys only after the round is verified on-chain#98
0xHansLee merged 1 commit into
mainfrom
fix/keygen-after-round-verification

Conversation

@0xHansLee

Copy link
Copy Markdown
Collaborator

Problem

GenerateAndSealKey mints sealed key files before checking that the requested round exists, so requests carrying arbitrary round numbers create key files on disk without bound.

Fix

Fetch the round's DKGNetwork and run verifyDKGStartBlock before LoadOrGenerate{Ed25519,Secp256k1}Key. Key material, report data, and quote contents are unchanged, and the load-or-generate path stays idempotent, so retried calls converge on the same sealed keys.

Context

Best merged together with #97: alone on main, the (unchanged) no-retry network read fails before key generation during a round-boundary light-client lag — functionally fine (the per-block session resume converges) but with avoidable MarkFailed churn.

Tests

No new tests — no behavior change for legitimate flows; existing service suite passes.

issue: none

… on-chain

GenerateAndSealKey minted sealed key files before checking that the
requested round exists, so requests carrying arbitrary round numbers
created key files without bound. Fetch and verify the round's DKG network
first; the key material and quote contents are unchanged.
@jinn-agent

jinn-agent Bot commented Aug 4, 2026

Copy link
Copy Markdown

The change correctly re-orders operations so that LoadOrGenerateEd25519Key and LoadOrGenerateSecp256k1Key are called only after GetDKGNetwork + verifyDKGStartBlock succeed. The moved code is functionally identical to what was removed; no logic inside the key-generation block changed. The load-or-generate semantics remain idempotent on retries as described in the PR. No high-confidence issues were found in the changed lines.


Review iteration 1 · Commit 6bdb340 · 2026-08-04T03:16:04Z

@wo-o wo-o left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found — see summary comment.

@0xHansLee
0xHansLee merged commit 48e4573 into main Aug 7, 2026
12 checks passed
@0xHansLee
0xHansLee deleted the fix/keygen-after-round-verification branch August 7, 2026 06:47
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.

2 participants