-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(mpz-ot): ferret clean up #173
Conversation
crates/mpz-ot/src/ferret/mod.rs
Outdated
/// Returns the number of COTs required to bootstrap an extension. | ||
pub(crate) fn bootstrap_rate(&self) -> usize { | ||
self.lpn_parameters.k as usize | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Returns the number of COTs required to bootstrap an extension. | |
pub(crate) fn bootstrap_rate(&self) -> usize { | |
self.lpn_parameters.k as usize | |
} | |
/// Returns the number of COTs required to bootstrap an extension. | |
pub(crate) fn bootstrap_rate(&self) -> usize { | |
self.lpn_parameters.k | |
} |
crates/mpz-ot/src/ferret/mpcot.rs
Outdated
let alphas = vec![0, 1, 3, 4, 2]; | ||
let t = alphas.len(); | ||
let n = 10; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The alphas
values are not regular, so the test fails.
Try to use a regular alphas
such as [0, 3, 4, 7, 9]
crates/mpz-ot/src/ferret/sender.rs
Outdated
let s = if sender.remaining() < self.config.bootstrap_rate() { | ||
mpcot::send(ctx, &mut self.rcot, delta, lpn_type, t, n).await? | ||
} else { | ||
mpcot::send( | ||
ctx, | ||
&mut BootstrappedSender(&mut sender), | ||
delta, | ||
lpn_type, | ||
t, | ||
n, | ||
) | ||
.await? | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think we should use self.rcot
to generate COTs in this step. It will only be used in the setup phase.
One optimization is to reserve enough COTs in the previous ferret extension for the next extension, and just read them for this step like BootstrappedSender
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the k
COTs are already reserved in Sender state (see v
).
crates/mpz-ot/src/ferret/receiver.rs
Outdated
let r = if receiver.remaining() < self.config.bootstrap_rate() { | ||
mpcot::receive(ctx, &mut self.rcot, lpn_type, alphas, n as u32).await? | ||
} else { | ||
mpcot::receive( | ||
ctx, | ||
&mut BootstrappedReceiver(&mut receiver), | ||
lpn_type, | ||
alphas, | ||
n as u32, | ||
) | ||
.await? | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar to Sender.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is much simpler! LGTM
Optimize the ferret extension process, rcot is only invoked in the setup phase, and buffer all the needed COTs in the extension phase. |
ty @xiangxiecrypto sorry this is taking so long on my end, im almost ready to focus back here again. Why move the buffering out into the io layer? Can't we use the existing buffer in core?
The tests in the kos module should give a sense of how to use the API. Or are you wondering how to use it with an actual network connection, eg TCP? |
I'm going to go ahead and merge this into the |
This PR does some simplification and clean up of the ferret impl.
Changes
spcot
andmpcot
impls, making them functionalRandomCOT: Default