-
Notifications
You must be signed in to change notification settings - Fork 16
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
feat: implement Beaver triple generation #335
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use super::state::{GeneratingState, NodeState, ResharingState}; | ||
use super::state::{GeneratingState, NodeState, ResharingState, RunningState}; | ||
use crate::http_client::{self, SendError}; | ||
use crate::protocol::message::{GeneratingMessage, ResharingMessage}; | ||
use crate::protocol::state::WaitingForConsensusState; | ||
|
@@ -163,6 +163,23 @@ impl CryptographicProtocol for ResharingState { | |
} | ||
} | ||
|
||
#[async_trait] | ||
impl CryptographicProtocol for RunningState { | ||
async fn progress<C: CryptographicCtx + Send + Sync>( | ||
mut self, | ||
ctx: C, | ||
) -> Result<NodeState, CryptographicError> { | ||
if self.triple_manager.potential_len() < 2 { | ||
self.triple_manager.generate(); | ||
} | ||
for (p, msg) in self.triple_manager.poke() { | ||
Comment on lines
+172
to
+174
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so, we're generating more triples on the fly when we run low? Won't this be very computationally expensive or since we're just generating one, it will be fine? But wouldn't that still impose a good amount of latency with all the messaging the triple generation protocol requires? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this is just pretty much a placeholder. We need to implement |
||
let url = self.participants.get(&p).unwrap(); | ||
http_client::message(ctx.http_client(), url.clone(), MpcMessage::Triple(msg)).await?; | ||
} | ||
Ok(NodeState::Running(self)) | ||
Comment on lines
+175
to
+178
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this correct that we should be doing all the messaging after the protocol completes? What if all nodes are waiting on messages and we'll be stuck in a deadlock? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, the protocol is interactive and occasionally you need to wait for other messages to arrive before you can progress. So ideally there should be a timeout and a restart mechanism but that hasn't been implemented yet. |
||
} | ||
} | ||
|
||
#[async_trait] | ||
impl CryptographicProtocol for NodeState { | ||
async fn progress<C: CryptographicCtx + Send + Sync>( | ||
|
@@ -172,6 +189,7 @@ impl CryptographicProtocol for NodeState { | |
match self { | ||
NodeState::Generating(state) => state.progress(ctx).await, | ||
NodeState::Resharing(state) => state.progress(ctx).await, | ||
NodeState::Running(state) => state.progress(ctx).await, | ||
_ => Ok(self), | ||
} | ||
} | ||
|
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.
hmm, why do we have both rand7 and rand8 in regular MPC?
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 don't think we need both versions anymore, but in the past there was some issue with one of the dependencies relying on rand being exactly 0.7