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

DKGResultVerification.verify byte inputs validation #1525

Merged
merged 4 commits into from Mar 30, 2020

Conversation

pdyraga
Copy link
Member

@pdyraga pdyraga commented Mar 30, 2020

Closes: #1524

Three additional validations added to bytes input parameters in DKGResultVerification.verify to limit the possibility of arbitrarily moving bytes between groupPubKey and misbehaved by the submitter:

  • groupPubKey must have exactly 128 bytes

    It is altbn128 G2 point in uncompressed form; it must have 128 bytes.

  • misbehaved can be up to group_size - signature_threshold bytes

    misbehaved can be empty or can have some elements but it can never have more elements than the group size minus the minimum DKG result signature threshold. No group member will vote on the result where it is marked as misbehaving. If the result is going to be accepted, it must have at least the minimum signature threshold. Hence, the maximum number of members indicated as misbehaving is group_size - signature_threshold. If the number of elements in misbehaved is higher than the client is broken or it's trying to cheat.

  • number of signatures supporting the result can not be higher than the group size

    The number of possible valid signatures should be limited by members array passed to verify function as a parameter. However, since DKGResultVerification library keeps a group size in its storage, it makes sense to do all the validation possible to make sure the internal state is consistent.

#1524, as per audit, recommends adding a salt between the group public key and misbehaved. This PR does not contain this change as I don't see a clear advantage of this, given that:

  • group public key should never be the same
  • we collected unique signatures from at least a threshold group members
  • we validate member eligibility to submit the result; if two or more members become eligible (possible when some of them become inactive or are late), we are fine with them racing for submission by design.

There could be no more misbehaved than the group size minus the minimum
signature threshold. For example for a group size of 64 members and
minimum threshold of 33 members supporting the result, we can have no
more than 31 misbehaving members.

Added validation to make the manipulation of DKG signature harder. We
now check the exact size of public key and maximum size of misbehaved
bytestring before we pass them to abi.encodePacked
The number of possible valid signatures should be limited by members
array passed to verify function as a parameter. However, since this
library keeps a group size in storage it makes sense to do all the
validation possible to make sure the internal state is consistent.
Because we now validate group public key in `verify` function, we need
to use a correct bytestring.
Copy link
Contributor

@eth-r eth-r left a comment

Choose a reason for hiding this comment

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

Looks good to me. The requirement for the pubkey to be always 128 bytes seems sufficient given the threshold requirement of signatures on the key; if no honest member signs a public key of invalid length, only a dishonest majority could pass a malformed key as correct and then they'd be caught when tasked with signing.

Copy link
Contributor

@ngrinkevich ngrinkevich left a comment

Choose a reason for hiding this comment

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

Looks good 🚀

@ngrinkevich ngrinkevich merged commit c057cd5 into master Mar 30, 2020
@ngrinkevich ngrinkevich deleted the dkg-result-validation branch March 30, 2020 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DKGResultVerification.verify unsafe packing in signed data
3 participants