Skip to content

Validator ordering changes#172

Merged
cygnusv merged 9 commits intonucypher:mainfrom
piotr-roslaniec:external-share-idx
Feb 5, 2024
Merged

Validator ordering changes#172
cygnusv merged 9 commits intonucypher:mainfrom
piotr-roslaniec:external-share-idx

Conversation

@piotr-roslaniec
Copy link
Copy Markdown

@piotr-roslaniec piotr-roslaniec commented Jan 25, 2024

Type of PR:

  • Other

Required reviews:

  • 1

What this does:

  • Replaces global validator ordering with canonical share indices in DKG instances
  • Replaces DkgValidator with Validator
  • Prevents panic when aggregating empty PVSS instances list
  • Deduplicates share utils/variables
  • Fixes some internal TODOs
  • Removes unused code

Issues fixed/closed:

  • Fixes #...

Why it's needed:

  • Removes some technical debt and lays the groundwork for other, functional issues

Notes for reviewers:

  • There's a lot of smaller changes that make understanding this PR a bit difficult. I've added comments in the PR itself as pointers to more important pieces.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 25, 2024

Codecov Report

Attention: 21 lines in your changes are missing coverage. Please review.

Comparison is base (de9cf36) 77.78% compared to head (72b8484) 78.28%.

Files Patch % Lines
ferveo/src/bindings_python.rs 50.00% 10 Missing ⚠️
ferveo/src/bindings_wasm.rs 0.00% 7 Missing ⚠️
ferveo/src/api.rs 96.22% 2 Missing ⚠️
ferveo/src/pvss.rs 93.33% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

self.address.cmp(&other.address)
}
/// The index of the validator in the given ritual
pub share_index: u32,
Copy link
Copy Markdown
Author

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

"num_shares: {num_shares}, security_threshold: {security_threshold}"
))
},
Error::DuplicatedShareIndex(index) => {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

New exceptions

.verify(dkg.0.dkg_params.shares_num(), &messages)
.is_ok());

// Test negative cases
Copy link
Copy Markdown
Author

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

}

#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
pub struct DkgValidator<E: Pairing> {
Copy link
Copy Markdown
Author

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>(
Copy link
Copy Markdown
Author

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

@piotr-roslaniec piotr-roslaniec marked this pull request as ready for review January 31, 2024 12:47
Ok(Message::Deal(transcript)) => Ok(transcript),
Err(e) => Err(e),
_ => Err(Error::InvalidDkgStateToDeal),
}
Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Author

@piotr-roslaniec piotr-roslaniec Feb 5, 2024

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 a Message struct, and specifically from Message::Deal variant. I'm considering deprecating Message 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 and Message:Aggregate. We treat results other than Message::Deal as errors, as we don't expect the DKG to be ready to aggregate at this point.

@cygnusv cygnusv merged commit 15776e7 into nucypher:main Feb 5, 2024
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.

3 participants