Skip to content
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

Merged
merged 3 commits into from
Aug 16, 2024
Merged

refactor(mpz-ot): ferret clean up #173

merged 3 commits into from
Aug 16, 2024

Conversation

sinui0
Copy link
Collaborator

@sinui0 sinui0 commented Jul 5, 2024

This PR does some simplification and clean up of the ferret impl.

Changes

  • Refactored to opaque error types
  • Removed state from spcot and mpcot impls, making them functional
  • Removed unnecessary generics
  • Removed some unsatisfiable trait bounds, eg RandomCOT: Default
  • Added buffering to the core types
  • Implemented iterative extension with one-time bootstrapping using injected RCOT
    • This still needs work, from my understanding the iterations can be performed in parallel. Right now we're doing them sequentially and that will have poor round complexity.

Comment on lines 46 to 49
/// Returns the number of COTs required to bootstrap an extension.
pub(crate) fn bootstrap_rate(&self) -> usize {
self.lpn_parameters.k as usize
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// 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
}

Comment on lines 151 to 153
let alphas = vec![0, 1, 3, 4, 2];
let t = alphas.len();
let n = 10;
Copy link
Collaborator

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]

Comment on lines 105 to 117
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?
};
Copy link
Collaborator

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.

Copy link
Collaborator

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).

Comment on lines 110 to 121
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?
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to Sender.

Copy link
Collaborator

@xiangxiecrypto xiangxiecrypto left a 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

@themighty1 themighty1 self-requested a review July 11, 2024 06:20
@xiangxiecrypto
Copy link
Collaborator

Optimize the ferret extension process, rcot is only invoked in the setup phase, and buffer all the needed COTs in the extension phase.
@sinui0 Is there any example of using KOS with io? Then I can set all the real parameters for Ferret.

@sinui0
Copy link
Collaborator Author

sinui0 commented Aug 16, 2024

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?

Is there any example of using KOS with io? Then I can set all the real parameters for Ferret.

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?

@sinui0
Copy link
Collaborator Author

sinui0 commented Aug 16, 2024

I'm going to go ahead and merge this into the ferret branch and we can continue there

@sinui0 sinui0 merged commit 116035e into ferret Aug 16, 2024
@sinui0 sinui0 deleted the ferret-sinu branch August 16, 2024 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants