118 lines
4.2 KiB
Protocol Buffer
118 lines
4.2 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
package mpc.router.v1;
|
|
|
|
option go_package = "github.com/rwadurian/mpc-system/api/grpc/router/v1;router";
|
|
|
|
// MessageRouter service handles MPC message routing
|
|
service MessageRouter {
|
|
// RouteMessage routes a message from one party to others
|
|
rpc RouteMessage(RouteMessageRequest) returns (RouteMessageResponse);
|
|
|
|
// SubscribeMessages subscribes to messages for a party (streaming)
|
|
rpc SubscribeMessages(SubscribeMessagesRequest) returns (stream MPCMessage);
|
|
|
|
// GetPendingMessages retrieves pending messages (polling alternative)
|
|
rpc GetPendingMessages(GetPendingMessagesRequest) returns (GetPendingMessagesResponse);
|
|
|
|
// RegisterParty registers a party with the message router (party actively connects)
|
|
rpc RegisterParty(RegisterPartyRequest) returns (RegisterPartyResponse);
|
|
|
|
// SubscribeSessionEvents subscribes to session lifecycle events (session start, etc.)
|
|
rpc SubscribeSessionEvents(SubscribeSessionEventsRequest) returns (stream SessionEvent);
|
|
|
|
// PublishSessionEvent publishes a session event (called by Session Coordinator)
|
|
rpc PublishSessionEvent(PublishSessionEventRequest) returns (PublishSessionEventResponse);
|
|
}
|
|
|
|
// RouteMessageRequest routes an MPC message
|
|
message RouteMessageRequest {
|
|
string session_id = 1;
|
|
string from_party = 2;
|
|
repeated string to_parties = 3; // Empty for broadcast
|
|
int32 round_number = 4;
|
|
string message_type = 5;
|
|
bytes payload = 6; // Encrypted MPC message
|
|
}
|
|
|
|
// RouteMessageResponse confirms message routing
|
|
message RouteMessageResponse {
|
|
bool success = 1;
|
|
string message_id = 2;
|
|
}
|
|
|
|
// SubscribeMessagesRequest subscribes to messages for a party
|
|
message SubscribeMessagesRequest {
|
|
string session_id = 1;
|
|
string party_id = 2;
|
|
}
|
|
|
|
// MPCMessage represents an MPC protocol message
|
|
message MPCMessage {
|
|
string message_id = 1;
|
|
string session_id = 2;
|
|
string from_party = 3;
|
|
bool is_broadcast = 4;
|
|
int32 round_number = 5;
|
|
string message_type = 6;
|
|
bytes payload = 7;
|
|
int64 created_at = 8; // Unix timestamp milliseconds
|
|
}
|
|
|
|
// GetPendingMessagesRequest retrieves pending messages
|
|
message GetPendingMessagesRequest {
|
|
string session_id = 1;
|
|
string party_id = 2;
|
|
int64 after_timestamp = 3; // Get messages after this timestamp
|
|
}
|
|
|
|
// GetPendingMessagesResponse contains pending messages
|
|
message GetPendingMessagesResponse {
|
|
repeated MPCMessage messages = 1;
|
|
}
|
|
|
|
// RegisterPartyRequest registers a party with the router
|
|
message RegisterPartyRequest {
|
|
string party_id = 1; // Unique party identifier
|
|
string party_role = 2; // persistent, delegate, or temporary
|
|
string version = 3; // Party software version
|
|
}
|
|
|
|
// RegisterPartyResponse confirms party registration
|
|
message RegisterPartyResponse {
|
|
bool success = 1;
|
|
string message = 2;
|
|
int64 registered_at = 3; // Unix timestamp milliseconds
|
|
}
|
|
|
|
// SubscribeSessionEventsRequest subscribes to session events
|
|
message SubscribeSessionEventsRequest {
|
|
string party_id = 1; // Party ID subscribing to events
|
|
repeated string event_types = 2; // Event types to subscribe (empty = all)
|
|
}
|
|
|
|
// SessionEvent represents a session lifecycle event
|
|
message SessionEvent {
|
|
string event_id = 1;
|
|
string event_type = 2; // session_created, session_started, etc.
|
|
string session_id = 3;
|
|
int32 threshold_n = 4;
|
|
int32 threshold_t = 5;
|
|
repeated string selected_parties = 6; // PartyIDs selected for this session
|
|
map<string, string> join_tokens = 7; // PartyID -> JoinToken mapping
|
|
bytes message_hash = 8; // For sign sessions
|
|
int64 created_at = 9; // Unix timestamp milliseconds
|
|
int64 expires_at = 10; // Unix timestamp milliseconds
|
|
}
|
|
|
|
// PublishSessionEventRequest publishes a session event
|
|
message PublishSessionEventRequest {
|
|
SessionEvent event = 1;
|
|
}
|
|
|
|
// PublishSessionEventResponse confirms event publication
|
|
message PublishSessionEventResponse {
|
|
bool success = 1;
|
|
int32 subscriber_count = 2; // Number of parties that received the event
|
|
}
|