Skip to content

Conversation

@anhthii
Copy link
Contributor

@anhthii anhthii commented Jun 26, 2025

Architecture Changes:

  • Refactored MPC package to use node-based architecture
  • Improved session management and party handling
  • Enhanced version management system
  • Session Management:

Implemented new session handling for both ECDSA and EDDSA

  • Added version tracking for key shares
  • Enhanced save data management in resharing process
  • Improved error handling in session management

vj3t and others added 30 commits June 26, 2025 13:50
* Add resharing functionality

* Add resharing functionality with new session management and event handling

* Refactor resharing session management to support old and new participants, enhance event handling, and update dependencies in go.mod

* Enhance resharing session by introducing new resharing parameters, updating message handling for resharing, and improving logging for better traceability.

* Refactor event consumer and session management to use specific resharing message handling methods, improving clarity and functionality in resharing processes.

* Update wallet ID in resharing example and refactor session management by removing unused methods and improving unsubscribe handling for broadcast and direct subscriptions.

* Refactor event consumer to improve resharing event handling by updating error channel references and enhancing logging for session completion.

* Refactor event consumer and resharing session to improve context management and logging, enhancing clarity in session completion handling.

* Enhance resharing functionality by introducing support for EDDSA key type, updating resharing session management, and improving message handling for resharing events. This includes the addition of new resharing session methods and error channel updates for better clarity and functionality.

* Add IsReshared field to KeyInfo struct and update key generation and resharing sessions to utilize this field. Enhance session management by differentiating between key generation and resharing based on the IsReshared status.

* Update wallet ID and key path in resharing and signing examples; remove unused session management method in event consumer. Enhance logging initialization in migration scripts.

* Refactor key saving methods in resharing sessions to improve code clarity and error handling. Introduce SaveKeyData and SaveKeyInfo methods for streamlined key and key info storage, ensuring proper logging and error management.

* Refactor topic and key formatting in ECDSA and EDDSA resharing sessions for improved clarity and consistency. Introduce constants for topic and key formats, enhancing maintainability and readability of the code.

---------

Co-authored-by: carmy <[email protected]>
Co-authored-by: vietddude <[email protected]>
Introduces a session-based architecture for managing MPC party interactions.

This change removes the direct logging from the party implementations and introduces an error channel for handling errors during the MPC process, allowing errors to be propagated to the session layer.

This change also introduces base session structs and implements EcdsaSession.
This commit refactors the MPC package to introduce a node-based architecture, enhancing the organization and clarity of the code. The changes include:

- Replacing direct references to the `mpc` package with a new `node` package for better modularity.
- Implementing a `Node` struct that encapsulates peer management and session handling.
- Updating event consumer and session management to utilize the new node structure, improving error handling and message processing.
- Removing unused methods and enhancing logging for better traceability.

These changes aim to streamline the MPC process and improve maintainability.
This commit refines the signing process and event consumer logic within the MPC package. Key changes include:

- Updated the main signing example to use a local NATS URL and modified the wallet ID and network code for consistency.
- Enhanced the event consumer to properly handle signing events, including improved error handling and logging.
- Introduced a session interface for better management of signing and key generation sessions, allowing for more modular and maintainable code.
- Refactored session methods to streamline the process of saving keys and handling errors, improving overall clarity and functionality.

These changes aim to enhance the robustness and maintainability of the MPC signing process.
This commit introduces significant changes to the event handling and session management within the MPC package. Key updates include:

- Replaced references to `mpc` events with a new `event` package, enhancing modularity and clarity.
- Updated the `OnWalletCreationResult` and `OnResharingResult` methods to utilize the new event types, improving type safety and consistency.
- Enhanced the resharing process by introducing a `KeyType` parameter in the `Resharing` method, allowing for better flexibility in key management.
- Removed deprecated ECDSA and EDDSA session files, streamlining the codebase and focusing on the new architecture.

These changes aim to improve the maintainability and clarity of the MPC package, facilitating future enhancements and reducing complexity.
This commit introduces the handling of signing result events within the event consumer, enhancing the signature verification process. Key updates include:

- Added `SigningResultEvent` struct to encapsulate signing results, including wallet ID, transaction ID, and signature details.
- Implemented signature verification logic in the event consumer, improving error handling and logging for signing operations.
- Introduced `GetSaveData` methods in both ECDSAParty and EDDSAParty to facilitate serialization of party state data.
- Added `VerifySignature` method in the ECDSASession to validate signatures against stored public keys, enhancing security and reliability.

These changes aim to improve the robustness and maintainability of the signing process within the MPC package.
This commit updates the signature verification process within the event consumer and session management. Key changes include:

- Modified the `VerifySignature` method in the `ECDSASession` to return a structured `common.SignatureData` instead of multiple return values, enhancing clarity and usability.
- Updated the event consumer to utilize the new signature verification method, improving error handling and logging.
- Removed unnecessary variables in the event consumer, streamlining the signature handling process.

These changes aim to improve the maintainability and robustness of the signature verification workflow in the MPC package.
This commit includes the following changes:

- Removed the version declaration from the `docker-compose.yaml` file for simplification.
- Updated the key path in `main.go` to a relative path for better portability.
- Refactored event topic constants in `event.go` to include the `mpc_` prefix for consistency.
- Modified the idempotent key in `event_consumer.go` to use a formatted string based on the wallet ID, enhancing clarity in message handling.

These changes aim to improve the organization and maintainability of the codebase.
This commit introduces several improvements to the MPC package, including:

- Updated the `CreateKeygenSession` method to handle both ECDSA and EDDSA key types, improving flexibility in session creation.
- Added a new `EDDSASession` struct to manage EDDSA key generation and signing processes, enhancing modularity.
- Refactored the event consumer to support the new EDDSA session, including improved error handling and logging for key generation and signing events.
- Modified the `VerifySignature` method in both ECDSASession and EDDSASession to return structured data, improving clarity and usability.

These changes aim to enhance the maintainability and robustness of the MPC package, facilitating future enhancements.
This commit introduces improvements to the save data management in the MPC package, including:

- Updated the `SetSaveData` method in both `ECDSAParty` and `EDDSAParty` to correctly handle deserialization of save data, ensuring proper assignment of local save data structures.
- Added a call to retrieve and set save data in the `CreateSigningSession` method of the `Node` struct, enhancing session management.

These changes aim to improve the reliability and clarity of the save data handling process within the MPC package.
This commit introduces the following changes to the MPC package:

- Added a new `consumeResharingEvent` method in the `eventConsumer` to handle resharing events, improving event processing and logging.
- Updated the `Node` struct to include a `CreateResharingSession` method, facilitating the creation of resharing sessions for both ECDSA and EDDSA key types.
- Refactored session methods to support resharing, including updates to the `Listen` method to differentiate between key generation and resharing sessions.
- Enhanced error handling and logging throughout the resharing process, ensuring better traceability and reliability.

These changes aim to improve the robustness and maintainability of the MPC package, particularly in managing resharing events and sessions.
This commit introduces several improvements to the MPC package, including:

- Updated the `runNode` function to allow debug logging based on the command-line flag, enhancing the configurability of logging.
- Improved the `consumeResharingEvent` method to build a local save data subset for resharing sessions, ensuring proper handling of session data.
- Refactored the `CreateResharingSession` method to differentiate between old and new party sessions, enhancing session management.
- Added logging for successful resharing completion, improving traceability of resharing events.

These changes aim to enhance the robustness and maintainability of the MPC package, particularly in managing resharing events and session data.
This commit introduces several key changes to the MPC package:

- Updated the `partyIDToNodeID` function to utilize the `Moniker` field of `tss.PartyID`, improving clarity in party ID representation.
- Refactored the `generatePartyIDs` function to maintain its functionality while ensuring consistency in party ID creation.
- Enhanced logging in the `Send` and `Listen` methods of the session to provide clearer output for message routing, including broadcasts and direct messages.

These changes aim to improve the maintainability and clarity of the MPC package, particularly in party ID management and session messaging.
This commit introduces several key updates to the MPC package:

- Added a `DefaultVersion` constant to standardize version handling across key generation and signing sessions.
- Updated the `SaveKey` method to accept a version parameter, improving clarity in key storage.
- Refactored the `CreateSigningSession` and `CreateResharingSession` methods to incorporate party versioning, enhancing session management.
- Improved error handling and logging in the event consumer for key generation and signing events, ensuring better traceability.

These changes aim to enhance the maintainability and robustness of the MPC package, particularly in managing session versions and key storage.
This commit includes the following changes:

- Updated the container names in `docker-compose.yaml` for clarity and consistency.
- Refactored the `eventConsumer` methods to replace `GetPartyVersion` with `GetKeyInfoVersion`, enhancing the accuracy of version management in transaction signing and resharing events.
- Improved error handling and logging in the `consumeTxSigningEvent` and `consumeResharingEvent` methods, ensuring better traceability of issues.

These changes aim to enhance the maintainability and clarity of the codebase, particularly in container management and event processing.
This commit introduces the following changes across multiple example files:

- Enabled Viper configuration initialization by uncommenting `config.InitViperConfig()`, allowing for dynamic configuration management.
- Updated the NATS URL retrieval to use `viper.GetString("nats.url")` instead of a hardcoded value, enhancing flexibility in environment configuration.
- Adjusted the key path in the `reshare` example to a relative path for improved portability.

These changes aim to enhance the configurability and maintainability of the example applications.
This commit includes the following changes:

- Updated the `NewEDDAParty` and `NewECDSASession` functions to remove the redundant `curve` parameter, simplifying session initialization.
- Refactored error handling in the `consumeTxSigningEvent` method to streamline the error processing flow, enhancing clarity and maintainability.

These changes aim to improve the readability and efficiency of the MPC package, particularly in session management and error handling.
This commit introduces a new `Close` method in the `Node` struct to handle peer registry resignation, enhancing resource management. Additionally, the `runNode` function is updated to defer the `Close` method call, ensuring proper cleanup of resources when the node operation completes. These changes aim to improve the robustness and maintainability of the MPC package by ensuring resources are released appropriately.
This commit introduces a new `PreloadPreParams` method in the `Node` struct to preload ECDSA preparameters, enhancing the initialization process. Additionally, the `partyIDToNodeID` function is renamed to `getRoutingFromPartyID` for improved clarity in routing party ID to node ID mapping. The `Send` and `Listen` methods in the session have been updated to utilize the new function, ensuring consistency in message routing. These changes aim to improve the maintainability and clarity of the MPC package, particularly in session initialization and party ID management.
This commit updates the `GetKeyInfoVersion` method in the `Node` struct to return -1 for invalid key types and errors, enhancing error handling. In the `consumeResharingEvent` method of the `eventConsumer`, the retrieval of the key info version is simplified by ignoring errors, defaulting to -1 if no key is found. These changes aim to improve the robustness and clarity of version management in the MPC package.
This commit modifies the handling of key versions across multiple files in the MPC package. The `KeyInfo` struct now uses an `int` for the version field instead of `uint16`, and the `DefaultVersion` constant is updated from 0 to 1. Additionally, the `GetKeyInfoVersion` method in the `Node` struct now returns 0 for invalid key types and errors, improving error handling consistency. The `consumeResharingEvent` method in the `eventConsumer` is also updated to reflect these changes, ensuring better clarity and robustness in version management.
This commit introduces several key updates across the MPC package, including:

- Updated the `TypeResharingSuccess` constant to include a version number for better version tracking.
- Modified the `Listen` method in the session interface to remove the `isResharing` parameter, simplifying the method signature.
- Implemented `ClassifyMsg` methods in both `ECDSAParty` and `EDDSAParty` to classify messages and determine their round and broadcast status.
- Enhanced logging in the `Send` and `receive` methods to include message round information, improving traceability.

These changes aim to improve the clarity and maintainability of the MPC package, particularly in event processing and message handling.
This commit updates the `Listen` method in the session interface to remove the `nodeID` parameter, simplifying its signature. Corresponding changes are made in the `eventConsumer` to reflect this update, enhancing the clarity and maintainability of event handling across the MPC package. These modifications aim to streamline the listening process for various session types.
This commit enhances the `consumeKeyGenerationEvent` method by introducing a context with a timeout for better control over key generation processes. The event handling logic is refactored to improve readability and maintainability, including the use of goroutines for concurrent processing of ECDSA and EDDSA sessions. Additionally, error handling and logging are improved to ensure better traceability of issues during key generation. These changes aim to streamline the key generation workflow and enhance the robustness of the event consumer.
@socket-security
Copy link

socket-security bot commented Jun 26, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedgithub.com/​nats-io/​nats.go@​v1.31.0 ⏵ v1.43.075 -3100100100100

View full report

@anhthii
Copy link
Contributor Author

anhthii commented Jun 26, 2025

bugbot run

1 similar comment
@anhthii
Copy link
Contributor Author

anhthii commented Jun 26, 2025

bugbot run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Infinite Listening Causes Goroutine Leaks

The signingSession.Listen() call within the consumeTxSigningEvent handler uses context.Background(). This prevents the listening goroutine from being properly cancelled or timing out, leading to potential goroutine leaks as it continues to run indefinitely even after the parent signing operation completes or times out.

pkg/eventconsumer/event_consumer.go#L334-L335

go signingSession.Listen(context.Background())

Fix in Cursor


BugBot free trial expires on July 22, 2025
You have used $0.00 of your $2.00 spend limit so far. Manage your spend limit in the Cursor dashboard.

Was this report helpful? Give feedback by reacting with 👍 or 👎

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@anhthii anhthii force-pushed the resharing-performance-optimization branch from 83c3761 to 0eaa6ab Compare June 26, 2025 15:10
@anhthii anhthii force-pushed the resharing-performance-optimization branch from 0eaa6ab to aeb1249 Compare June 26, 2025 15:26
@anhthii anhthii closed this Jun 27, 2025
@anhthii anhthii reopened this Jun 28, 2025
@anhthii anhthii closed this Jul 3, 2025
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.

5 participants