Skip to content

Move ECDH public key setting to generateDKGPolyV3 - #529

Draft
PropzSaladaz wants to merge 3 commits into
developfrom
IS/1475-improve-dkg-v3
Draft

Move ECDH public key setting to generateDKGPolyV3#529
PropzSaladaz wants to merge 3 commits into
developfrom
IS/1475-improve-dkg-v3

Conversation

@PropzSaladaz

@PropzSaladaz PropzSaladaz commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Description

This PR updates DKG v3 persistence and cleanup paths to use atomic LevelDB batch operations and updates dkg flow into a safer version.

What changed:

  1. Added batch write support in the LevelDB wrapper:
  • New writeBatch API for atomic put/delete operations in a single DB commit.
  • Optional uniqueness check for put keys before commit.
  • Locking around the check+write sequence in the batch path.
  1. Updated DKG v3 creation flow:
  • generateDKGPolyV3 now persists the polynomial payload and DKG metadata in one atomic batch write.
  • These keys will be used by any generateSecretSharesV3 call. The call now only requires poly_name. No longer expects ECDH public keys.
  1. Updated DKG cleanup flows:
  • complaintResponse and createBLSPrivateKeyV3 cleanup now remove all DKG-related keys via a single atomic batch delete operation.

  • Cleanup includes DH keys, shareG2 entries, polynomial entry, encrypted secret share entry, and DKG metadata entry.

  • Please see https://github.com/skalenetwork/internal-support/issues/1474

Fixes https://github.com/skalenetwork/internal-support/issues/1475

@PropzSaladaz PropzSaladaz self-assigned this Jun 22, 2026
Copilot AI review requested due to automatic review settings June 22, 2026 17:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the DKG v3 flow to persist recipient-binding metadata (t/n + ordered recipient ECDH public keys) alongside the encrypted polynomial, introduces a getSecretShareV3 endpoint that derives recipients from that metadata (instead of caller-provided keys), and consolidates DKG-related cleanup into atomic LevelDB batch deletes. It also adds a generic LevelDB writeBatch() API to support atomic put/delete operations.

Changes:

  • Added LevelDB::writeBatch() for atomic multi-key put/delete commits, with an optional “require new keys” pre-check.
  • Updated DKG v3 polynomial generation to require (n, publicKeys) and to persist polynomial + binding metadata atomically.
  • Added getSecretShareV3 (JSON-RPC + ZMQ) and updated cleanup paths to delete all DKG v3 artifacts (incl. metadata) via a single batch operation; updated tests/spec accordingly.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
zmq_src/ZMQMessage.h Adds ZMQ request type/enum for getSecretShareV3.
zmq_src/ZMQMessage.cpp Wires GET_SECRET_SHARE_V3_REQ into request factory/map.
zmq_src/ZMQClient.h Extends generateDKGPolyV3 signature; adds getSecretShareV3.
zmq_src/ZMQClient.cpp Sends new params for generateDKGPolyV3; implements getSecretShareV3.
zmq_src/ReqMessage.h Adds request message class for getSecretShareV3.
zmq_src/ReqMessage.cpp Parses new generateDKGPolyV3 params; implements getSecretShareV3 request processing.
WalletDBKeys.h Introduces DKG_META_V1_PREFIX for v3 binding metadata storage.
testw.cpp Updates DKG v3 API tests to pass recipient keys to generation and use getSecretShareV3.
TestUtils.cpp Updates DKG v3 rotation helpers to use new gen/signature and getSecretShareV3.
stubclient.h Updates JSON-RPC client wrapper for new generateDKGPolyV3 params; adds getSecretShareV3.
spec.json Documents updated generateDKGPolyV3 params and new getSecretShareV3 method.
SGXWalletServer.hpp Updates server interface: new params for generateDKGPolyV3, adds getSecretShareV3.
SGXWalletServer.cpp Implements metadata binding, atomic persistence, getSecretShareV3, and batch cleanup deletes.
sgxwallet_common.h Adds new error codes for v3 pubkey validation and metadata mismatch cases.
LevelDB.h Declares writeBatch() API.
LevelDB.cpp Implements writeBatch() using LevelDB WriteBatch.
abstractstubserver.h Updates JSON-RPC method signature for generateDKGPolyV3; registers getSecretShareV3.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread SGXWalletServer.cpp
Comment thread LevelDB.cpp
Comment thread spec.json
Comment thread spec.json
Comment thread abstractstubserver.h
Comment thread LevelDB.cpp
@PropzSaladaz
PropzSaladaz marked this pull request as draft July 3, 2026 15:31
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