Skip to content

Implement ECDH for P2P message encryption#95

Merged
anhthii merged 13 commits intomasterfrom
dev
Aug 21, 2025
Merged

Implement ECDH for P2P message encryption#95
anhthii merged 13 commits intomasterfrom
dev

Conversation

@anhthii
Copy link
Contributor

@anhthii anhthii commented Aug 21, 2025

This is to address the proposal #66

Related PR: #71

Summary

This PR introduces significant improvements to the MPC (Multi-Party Computation) cluster's resilience and error handling capabilities. The changes focus on making the system more robust when dealing with node disconnections, rejoin scenarios, and ensuring proper error handling during key generation and signing operations.

Key Changes

ECDH Service Refactoring

  • Refactored ECDH service to become resilient to node disconnect and rejoin scenarios
  • Improved key exchange session management with better cleanup and state handling
  • Enhanced registry functionality with more robust node management

Enhanced Error Handling

  • Added cluster readiness validation - now returns appropriate errors when cluster is not ready during key generation
  • Implemented majority node validation for signing operations with proper error handling when insufficient nodes are available
  • Added context cancellation checks to prevent operations on cancelled contexts

Improved Robustness

  • Fixed rejoining ECDH bugs with proper cache key cleaning
  • Enhanced node identity management with better state tracking
  • Streamlined main application logic by moving complexity to appropriate service layers

Files Modified

  • cmd/mpcium/main.go - Simplified main application logic
  • pkg/event/types.go - Added new error types for better error classification
  • pkg/eventconsumer/keygen_consumer.go - Enhanced key generation with cluster readiness checks
  • pkg/eventconsumer/sign_consumer.go - Improved signing with majority validation and error handling
  • pkg/identity/identity.go - Better identity state management
  • pkg/mpc/key_exchange_session.go - Refactored for improved session handling
  • pkg/mpc/node.go - Simplified node management logic
  • pkg/mpc/registry.go - Significantly enhanced registry with better node lifecycle management

Impact

  • Improved system stability during node disconnection/reconnection scenarios
  • Better error reporting for cluster state issues
  • Reduced likelihood of hanging operations through proper context handling
  • Enhanced debugging capabilities with more descriptive error messages

nann-cheng and others added 13 commits August 13, 2025 17:04
#71)

* fix typo

* draft impl for diffie hellman exchange

* New Feature: add p2p channel among nodes, enabling authenticated encryption

* decrease delay

* suppress warning

* increase delay for starting client

* increase delay in test case, supporess github security warning

* fix p2p feature correctness

* fix p2p feature

* fix format error

* revert old testing config

* correct log & remove useless comment

* avoid p2p message via nats message layer

* change to modern x25519 curve for ecdh

* Minor cleanup

* Consistent naming convention Id -> ID

* Wait for ECDH session to complete before starting consumers

* Code refactoring, better naming convention

* Refactor aes encryption

* Error handling for ecdh session

* Refactor session

* Fix security warning on AES encryption

* Update ci/cd

---------

Co-authored-by: anhthii <nguyendanganhthi247@gmail.com>
Enhanced MPC Cluster Resilience and Error Handling
Enhanced MPC Cluster Resilience and Error Handling
@anhthii anhthii merged commit 9cf994c into master Aug 21, 2025
29 of 31 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.

2 participants

Comments