OptimizedPrivateSetAnalytics<T>

Models & Types · AiDotNet.FederatedLearning.PSI

Implements Optimized Private Set Analytics (OPSA) beyond basic intersection.

Inheritance: FederatedLearningComponentBase<T> → OptimizedPrivateSetAnalytics<T>

For Beginners

Standard PSI (Private Set Intersection) tells you which items two parties share in common. OPSA extends this to richer analytics: set union cardinality (how many unique items total?), frequency estimation (how common is each item?), and threshold queries (which items appear in at least k parties?). All operations are private — no party learns the other parties’ raw sets.

How It Works

Supported operations:

Reference: Optimized Private Set Analytics for Federated Learning (2025).

Constructors

Constructor Summary
OptimizedPrivateSetAnalytics(int sketchWidth, int sketchDepth, int hllPrecision, int seed) Creates a new OPSA instance.

Properties

Property Summary
int HLLPrecision { get; } Gets the HyperLogLog precision parameter (p).
int HLLRegisterCount { get; } Gets the number of HyperLogLog registers (2^p).
int SketchDepth { get; } Gets the sketch depth.
int SketchWidth { get; } Gets the sketch width.

Methods

Method Summary
Dictionary<string, int> ThresholdQuery(int[] mergedSketch, IEnumerable<string> candidateItems, int threshold) Finds items from a candidate set that appear at least threshold times across all parties, using merged count-min sketches.
List<int[]> CreateSecretShares(int[] sketch, int numShares) Creates additive secret shares of a count-min sketch for threshold queries.
byte[] CreateHLLRegisters(IEnumerable<string> items) Creates a HyperLogLog register array from a set of items.
byte[] MergeHLLRegisters(IReadOnlyList<byte[]> registerSets) Merges HLL registers from multiple parties (element-wise max).
double EstimateCardinality(byte[] registers) Estimates the cardinality (number of distinct elements) from HLL registers.
double EstimateIntersectionCardinality(byte[] registersA, byte[] registersB) Estimates intersection cardinality of two parties using inclusion-exclusion: |A ∩ B| = |A| + |B| - |A ∪ B|.
double EstimateJaccardSimilarity(byte[] registersA, byte[] registersB) Estimates the Jaccard similarity between two parties: |A ∩ B| / |A ∪ B|.
double EstimateUnionCardinality(IReadOnlyList<byte[]> clientRegisters) Estimates union cardinality by merging HLL registers from multiple parties.
int EstimateFrequency(int[] mergedSketch, string item) Estimates the frequency of an item from merged sketches.
int[] CreateSketch(IEnumerable<string> items) Creates a count-min sketch from a set of items.
int[] MergeSketches(IReadOnlyList<int[]> sketches) Merges sketches from multiple parties (element-wise sum).