-
Notifications
You must be signed in to change notification settings - Fork 10
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
Validator ordering changes #172
Conversation
ddd5746
to
830cbc8
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #172 +/- ##
==========================================
+ Coverage 77.78% 78.28% +0.49%
==========================================
Files 25 24 -1
Lines 5074 5066 -8
==========================================
+ Hits 3947 3966 +19
+ Misses 1127 1100 -27 ☔ View full report in Codecov by Sentry. |
4a41d31
to
280c37e
Compare
0f3b9f4
to
4af8017
Compare
d402183
to
f6adf83
Compare
f6adf83
to
72b8484
Compare
self.address.cmp(&other.address) | ||
} | ||
/// The index of the validator in the given ritual | ||
pub share_index: u32, |
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.
DKG expects to be provided with a share_index
for every Validator
@@ -109,6 +108,14 @@ impl From<FerveoPythonError> for PyErr { | |||
"num_shares: {num_shares}, security_threshold: {security_threshold}" | |||
)) | |||
}, | |||
Error::DuplicatedShareIndex(index) => { |
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.
New exceptions
@@ -637,6 +658,41 @@ mod test_ferveo_api { | |||
assert!(local_aggregate | |||
.verify(dkg.0.dkg_params.shares_num(), &messages) | |||
.is_ok()); | |||
|
|||
// Test negative cases |
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.
These test cases were adapted from the server variant of tests above
@@ -61,35 +63,27 @@ impl DkgParams { | |||
} | |||
} | |||
|
|||
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)] | |||
pub struct DkgValidator<E: Pairing> { |
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.
Deprecated and replaced with just Validator
}) | ||
} | ||
} | ||
|
||
pub fn assert_no_share_duplicates<E: Pairing>( |
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.
Replaces validation logic for ensuring validator ordering
Ok(Message::Deal(transcript)) => Ok(transcript), | ||
Err(e) => Err(e), | ||
_ => Err(Error::InvalidDkgStateToDeal), | ||
} |
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.
What does this block code do?
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's a pattern-matching expression with different cases on each line:
- The first line describes a case where we get the intended result - We just need to unwrap
transcript
from aMessage
struct, and specifically fromMessage::Deal
variant. I'm considering deprecatingMessage
as we only use it internally. - The second line handles the error result
- The third one handles other
Message
variants. There are two currently,Message::Deal
andMessage:Aggregate
. We treat results other thanMessage::Deal
as errors, as we don't expect the DKG to be ready to aggregate at this point.
Type of PR:
Required reviews:
What this does:
DkgValidator
withValidator
Issues fixed/closed:
Why it's needed:
Notes for reviewers: