[][src]Module xaynet::state_machine

The state machine that controls the execution of the PET protocol.

Overview

The StateMachine is responsible for executing the individual tasks of the PET protocol. The main tasks include: building the sum and seed dictionaries, aggregating the masked models, determining the applicable mask and unmasking the global masked model.

Furthermore, the StateMachine publishes protocol events and handles protocol errors.

The StateMachine as well as the PET settings can be configured in the config file. See here for more details.

Phase states

Idle

Publishes PhaseEvent::Idle, increments the round id by 1, invalidates the SumDict, SeedDict, scalar and mask length, updates the EncryptKeyPair, thresholds as well as the seed and publishes the EncryptKeyPair and the RoundParameters.

Sum

Publishes PhaseEvent::Sum, builds and publishes the SumDict, ensures that enough sum messages have been submitted and initializes the SeedDict.

Update

Publishes PhaseEvent::Update, publishes the scalar, builds and publishes the SeedDict, ensures that enough update messages have been submitted and aggregates the masked model.

Sum2

Publishes PhaseEvent::Sum2, builds the MaskDict, ensures that enough sum2 messages have been submitted and determines the applicable mask for unmasking the global masked model.

Unmask

Publishes PhaseEvent::Unmask, unmasks the global masked model and publishes the global model.

Error

Publishes PhaseEvent::Error and handles StateErrors that can occur during the execution of the StateMachine. In most cases, the error is handled by restarting the round. However, if a StateError::ChannelError occurs, the StateMachine will shut down.

Shutdown

Publishes PhaseEvent::Shutdown and shuts down the StateMachine. During the shutdown, the StateMachine performs a clean shutdown of the Request channel by closing it and consuming all remaining messages.

Requests

By initiating a new StateMachine via StateMachine::new(), a new Request channel is created, the function of which is to send Requests to the StateMachine. The sender half of that channel (RequestSender) is returned back to the caller of StateMachine::new(), whereas the receiver half (RequestReceiver) is used by the StateMachine.

Note
    Note: Requests are only processed in the states
    Sum, Update or Sum2.

If the Request type and the state of the state machine do not match, the Request is ignored and the sender of the request receives a PetError::InvalidMessage

See here for more details.

Events

During the execution of the PET protocol, the StateMachine will publish various events (see Phase states). Everyone who is interested in the events can subscribe to the respective events via the EventSubscriber. An EventSubscriber is automatically created when a new StateMachine is created through StateMachine::new().

See here for more details.

Modules

coordinator

Coordinator state and round parameter types.

events

This module provides the StateMachine's Events, EventSubscriber and EventPublisher types.

phases

This module provides the PhaseStates of the StateMachine.

requests

This module provides the the StateMachine's Request, RequestSender and RequestReceiver types.

Enums

RoundFailed

Error that occurs when unmasking of the global model fails.

StateMachine

The state machine with all its states.

Type Definitions

TracingStateMachine

A StateMachine that processes Traced<Request>.