Table of Contents

Class ThresholdSecureAggregationVector<T>

Namespace
AiDotNet.FederatedLearning.Privacy
Assembly
AiDotNet.dll

Implements dropout-resilient secure aggregation for vector-based model updates.

public sealed class ThresholdSecureAggregationVector<T> : FederatedLearningComponentBase<T>, IDisposable

Type Parameters

T

The numeric type for model parameters (e.g., double, float).

Inheritance
ThresholdSecureAggregationVector<T>
Implements
Inherited Members

Remarks

For Beginners: Secure aggregation lets the server compute the sum/average of client updates without learning any single client's update. Each client adds random "masks" to its update. When the server combines all masked updates, the masks cancel out and the server recovers only the aggregate.

This variant is dropout-resilient:

  • Some clients may fail to upload masked updates (upload dropout).
  • Some clients may upload but fail to complete the unmasking step (unmasking dropout).

As long as enough clients complete the unmasking step (the reconstruction threshold), the server can still recover the aggregate by reconstructing missing self-masks using Shamir secret sharing and by removing leftover pairwise masks for clients that did not upload.

Reference: Bonawitz, K., et al. (2017). "Practical Secure Aggregation for Privacy-Preserving Machine Learning."

Constructors

ThresholdSecureAggregationVector(int, int?)

public ThresholdSecureAggregationVector(int parameterCount, int? randomSeed = null)

Parameters

parameterCount int
randomSeed int?

Properties

MinimumUploaderCount

Gets the minimum number of clients that must upload masked updates for the round to succeed.

public int MinimumUploaderCount { get; }

Property Value

int

ReconstructionThreshold

Gets the reconstruction threshold required to complete unmasking.

public int ReconstructionThreshold { get; }

Property Value

int

Methods

AggregateSecurely(Dictionary<int, Vector<T>>, Dictionary<int, double>)

public Vector<T> AggregateSecurely(Dictionary<int, Vector<T>> maskedUpdates, Dictionary<int, double> clientWeights)

Parameters

maskedUpdates Dictionary<int, Vector<T>>
clientWeights Dictionary<int, double>

Returns

Vector<T>

AggregateSecurely(Dictionary<int, Vector<T>>, Dictionary<int, double>, IReadOnlyCollection<int>?)

public Vector<T> AggregateSecurely(Dictionary<int, Vector<T>> maskedUpdates, Dictionary<int, double> clientWeights, IReadOnlyCollection<int>? unmaskingClientIds)

Parameters

maskedUpdates Dictionary<int, Vector<T>>
clientWeights Dictionary<int, double>
unmaskingClientIds IReadOnlyCollection<int>

Returns

Vector<T>

AggregateSumSecurely(Dictionary<int, Vector<T>>)

public Vector<T> AggregateSumSecurely(Dictionary<int, Vector<T>> maskedUpdates)

Parameters

maskedUpdates Dictionary<int, Vector<T>>

Returns

Vector<T>

AggregateSumSecurely(Dictionary<int, Vector<T>>, IReadOnlyCollection<int>?)

public Vector<T> AggregateSumSecurely(Dictionary<int, Vector<T>> maskedUpdates, IReadOnlyCollection<int>? unmaskingClientIds)

Parameters

maskedUpdates Dictionary<int, Vector<T>>
unmaskingClientIds IReadOnlyCollection<int>

Returns

Vector<T>

ClearSecrets()

public void ClearSecrets()

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

~ThresholdSecureAggregationVector()

protected ~ThresholdSecureAggregationVector()

InitializeRound(List<int>, int, int, double)

Initializes a new secure aggregation round by generating the required cryptographic material.

public void InitializeRound(List<int> clientIds, int minimumUploaderCount = 0, int reconstructionThreshold = 0, double maxDropoutFraction = 0.2)

Parameters

clientIds List<int>

Selected clients for the round.

minimumUploaderCount int

Minimum number of clients that must upload masked updates (0 = auto).

reconstructionThreshold int

Minimum number of clients that must complete unmasking (0 = auto).

maxDropoutFraction double

Used only when minimumUploaderCount is 0 (auto).

Remarks

If minimumUploaderCount or reconstructionThreshold are not set (0), industry-standard defaults are computed based on the selected clients.

MaskUpdate(int, Vector<T>)

public Vector<T> MaskUpdate(int clientId, Vector<T> clientUpdate)

Parameters

clientId int
clientUpdate Vector<T>

Returns

Vector<T>

MaskUpdate(int, Vector<T>, double)

public Vector<T> MaskUpdate(int clientId, Vector<T> clientUpdate, double clientWeight)

Parameters

clientId int
clientUpdate Vector<T>
clientWeight double

Returns

Vector<T>