privacy-scaling-explorations / mpz

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

add ferret with io #137

Closed xiangxiecrypto closed 2 months ago

xiangxiecrypto commented 3 months ago

Note that in the Ferret implementation, we need two random COTs. One for MPCOT (SPCOT), which can be IKNP-type (KOS) Random COTs. The other one is for the setup in Ferret, which will be Ferret with smaller parameters.

All the parameters will be chosen when the lpn estimator is done.

sinui0 commented 3 months ago

Great, thanks! Will review soon.

xiangxiecrypto commented 3 months ago

Excited to see it all come together! 🔥

I have some requests which should simplify things quite a bit.

  1. For MPCOT, I believe we can eliminate a lot of duplication by encapsulating the different LPN types (regular/uniform). Instead of having two types you can add an argument to the constructor and handle it behind the API. The core types can remain separate but the IO wrapper can be unified.

Yep, we can simplify mpcot to just one type.

  1. The check and finalize methods should not be exposed in the public API. When calling extend the user should just provide the number of OTs they want and you handle the entire process for them. Additionally, extend should not return the OTs, it should buffer them internally because it is used during the preprocessing phase. This buffering should be performed in the core crate, the same as how we do it for KOS.

Maybe we can keep spcot and mpcot internal apis, since they are only called by ferret. In this case, we do not need to keep all the output in internal states, it is much easier to be integrated by ferret.

As to finalize, I meant to explicitly close the extension procedure of ferret. In KOS, the state will automatically turn to Complete after the check procedure (if I understand correctly). While in ferret, it will always allow us to extend, unless we manually turn it off with finalize.

For example, here is what the public API could look like:

impl<RandomCOT> Sender<RandomCot> {
  pub fn new(lpn_type: LpnType, rcot: RandomCOT) -> Self { .. }

  pub async fn setup<Ctx: Context>(&mut self, ctx: &mut Ctx) 
    -> Result<(), SenderError> { .. }

  /// Preprocesses `count` OTs.
  pub async fn extend<Ctx: Context>(&mut self, ctx: &mut Ctx, count: usize)
    -> Result<(), SenderError> { .. }
}

This applies to SPCOT, MPCOT and Ferret

sinui0 commented 3 months ago

Maybe we can keep spcot and mpcot internal apis, since they are only called by ferret. In this case, we do not need to keep all the output in internal states, it is much easier to be integrated by ferret.

Yes, we can keep SPCOT and MPCOT private for now to simplify things.

As to finalize, I meant to explicitly close the extension procedure of ferret. In KOS, the state will automatically turn to Complete after the check procedure (if I understand correctly). While in ferret, it will always allow us to extend, unless we manually turn it off with finalize.

Ok, I see the intent now. I'm not sure if that is necessary though. For KOS we only do this because the consistency check is leaky and we did not see any proofs that leakage of Delta is bounded when running multiple extensions. For Ferret, my understanding is that extension can be performed indefinitely, is that correct?