Overview
Duchies collaborate to execute MPC protocols that compute aggregate metrics without revealing individual user data. The duchy protocol APIs provide:- Encrypted data exchange - Duchies pass encrypted sketches through computation stages
- Work claiming - Duchies claim computation work from the shared work queue
- Stage coordination - Track progress through multi-stage protocols
- Participant management - Coordinate which duchies participate in each computation
MPC Protocol Architecture
Key Services
Computations Service
Manages computation lifecycle from duchy perspective:GetComputation- Retrieve computation detailsStreamActiveComputations- Long-lived stream of active computationsSetComputationResult- Submit final encrypted result
Computation Control Service
Coordinates computation advancement between duchies:AdvanceComputation- Send encrypted data to next duchy in sequenceGetComputationStage- Query current computation stage
Computation Participants Service
Manages duchy participation in computations:- Register duchy as participant
- Confirm readiness for computation
- Update participant state
Computation Streaming
Duchies use long-lived streams to monitor for new work:StreamActiveComputations
Token indicating where to resume streamingUsed for fault tolerance and resuming after disconnection.
An active computation resourceComputations may appear multiple times if updated during stream lifetime.
Token for subsequent requests to resume streamShould be persisted by duchies for crash recovery.
Computation States
Current state of the computationValues:
PENDING_REQUISITION_PARAMS- Awaiting duchy parametersPENDING_REQUISITION_FULFILLMENT- Awaiting data provider sketchesPENDING_PARTICIPANT_CONFIRMATION- Duchies confirming participationPENDING_COMPUTATION- MPC protocol execution in progressSUCCEEDED- Computation completed successfully (terminal)FAILED- Computation failed (terminal)CANCELLED- Cancelled by measurement consumer (terminal)
Protocol Execution Flow
Liquid Legions V2 (3 Duchies)
Honest Majority Share Shuffle (3 Duchies)
Setting Computation Result
The aggregator duchy submits the final result:SetComputationResult
Resource name of the computationFormat:
computations/{computation}Certificate resource name of the aggregator duchyFormat:
duchies/{duchy}/certificates/{certificate}Used to verify the signed result.Serialized encryption public key from measurement consumerThe result is encrypted with this key.
Encrypted and signed Result messageContains:
- Encrypted metric value (reach, frequency histogram, etc.)
- Signature from aggregator duchy
- Metadata about computation
Version of the public API for message serializationExample:
"v2alpha"MPC Protocol Configuration
Each computation includes protocol-specific configuration:Liquid Legions V2 Config
Configuration for Liquid Legions V2 protocolFields:
sketch_params.decay_rate- Sketch decay rate (e.g., 12.0)sketch_params.max_size- Maximum sketch size (e.g., 100000)mpc_noise.blinded_histogram_noise- DP params for histogram noisempc_noise.publisher_noise- DP params for publisher noiseelliptic_curve_id- OpenSSL curve ID (e.g., 415 for prime256v1)noise_mechanism- GEOMETRIC, DISCRETE_GAUSSIAN, or CONTINUOUS_GAUSSIAN
Honest Majority Share Shuffle Config
Configuration for HMSS protocolFields:
reach_and_frequency_ring_modulus- Modulus for R&F (e.g., 2^32)reach_ring_modulus- Modulus for reach-only (e.g., 2^16)noise_mechanism- Noise generation method
Computation Participants
Each computation has multiple duchy participants:Denormalized list of participating duchiesEach participant includes:
name- Participant resource nameduchy_id- Duchy identifierstate- Participant-specific staterequisitions- Requisitions assigned to this duchy
Requisition Assignment
Requisitions are assigned to duchy participants:Work Claiming Pattern
Duchies implement a work queue pattern:Security Considerations
Mutual TLS Required
Mutual TLS Required
All duchy-to-duchy communication must use mutual TLS with certificate verification. Never accept connections from untrusted duchies.
Verify Computation State
Verify Computation State
Before processing a computation, verify it’s in the expected state. Protocol violations could compromise security.
Validate Encrypted Data
Validate Encrypted Data
Verify that encrypted data received from other duchies uses correct encryption schemes and key versions.
Isolate Computation Workers
Isolate Computation Workers
Run computation workers in isolated processes or containers to prevent cross-computation information leakage.
Audit All Operations
Audit All Operations
Log all computation operations with duchy identifiers, computation IDs, stages, and timestamps for security auditing.
Rate Limit Connections
Rate Limit Connections
Implement rate limiting on streaming RPCs and data transfer to prevent resource exhaustion attacks.
Error Handling
Invalid computation name or parametersResolution: Verify resource names and protocol configuration
Computation not found or not visible to this duchyResolution: Verify duchy is a participant in the computation
Computation not in correct stateCommon causes:
- Trying to advance computation that’s not ready
- Submitting result before all stages complete
Operation aborted due to concurrent modificationResolution: Retry operation with updated computation state
Computation took too long to completeResolution: Increase computation timeout or optimize processing
Performance Optimization
Stream multiplexing
Stream multiplexing
Use a single
StreamActiveComputations connection per duchy rather than multiple streams to reduce overhead.Parallel computation processing
Parallel computation processing
Process multiple independent computations in parallel using worker pools to maximize throughput.
Chunk size optimization
Chunk size optimization
When streaming data via
AdvanceComputation, use 1-4MB chunks to balance memory usage and network efficiency.Continuation token persistence
Continuation token persistence
Persist continuation tokens frequently (after each computation update) to minimize reprocessing after crashes.
Computation result caching
Computation result caching
Cache intermediate computation results to avoid recomputation if a stage needs to be retried.
Related APIs
Computation Control
Detailed computation control service documentation
Requisition Fulfillment
How data providers fulfill requisitions