privacy-scaling-explorations / mpz

Multi-party computation libraries written in Rust 🦀
182 stars 39 forks source link

refactor: KOS and preprocessing traits #155

Closed sinui0 closed 3 months ago

sinui0 commented 3 months ago

This PR adds traits for the preprocessing model and also updates KOS to implement random OT for any Standard: Distribution<T> type.

Allocate trait rationale

It is difficult to properly model preprocessing in the case where a functionality is shared by multiple others. One approach would be to update the preprocess function so that it has a count argument then use some sort of async Barrier for synchronization. That approach doesn't work in the case where multiplexing isn't available (only 1 context).

The approach I settled on was to decouple reserving capacity step from execution of the preprocessing. The implemented model is 2 steps:

  1. A functionality is injected as a sub-protocol into other protocols. Those protocols themselves implement Allocate, which allocate what they need from the sub-protocol. This process does not requires synchronization.
  2. Once all protocols have allocated what they need, Preprocess is called which actually executes the preprocessing all batched together.

Modeling it this way works for both cases where a functionality is "shared" or owned directly by another protocol.

Side note: Once we have SoftSpoken which can be extended multiple times, we should be able to just share the base OT and perform OT extensions in parallel instead of this batching. This will remove the need for shared state synchronization and be more performant in terms of latency and compute.