-
Notifications
You must be signed in to change notification settings - Fork 0
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
Implemented deriveInterpolatingValue function #7
Conversation
deriveInterpolatingValue implements def derive_interpolating_value(L, x_i) function from [FROST], as defined in section 4.2 Polynomials. deriveInterpolatingValue is a simplified version of the algorithm for computing Lagrange coefficient given we only care about the value f(0) instead of reconstructing the entire polynomial. L is the list of the indices of the members of the particular group. xi is the index of the participant i.
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.
Found one real error stemming from the prototype implementation. Also one minor documentation detail.
// for x_j in L: | ||
// if count(x_j, L) > 1: | ||
// raise "invalid parameters" | ||
if found { |
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.
This doesn't actually implement the specified functionality. We need to expect that the indices L
are sorted in ascending order, with no repeated instances, and keep track of the previous x_j'
. Comparing x_j
to x_j'
and requiring that x_j > x_j'
gives the specified functionality. This was a genuine oversight in the prototype.
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.
That's true though looking at Round2
implementation in #8 I do wonder if we need to worry about it in deriveInterpolatingValue
at all. validateGroupCommitments
makes sure that all commitments are sorted in ascending order and there is no duplicates.
We could improve unit tests for validateGroupCommitments
to cover duplicates and make it clear in deriveInterpolatingValue
that the validation must happen before this function is called.
This would allow us to eliminate this error handling:
Lines 120 to 125 in 5795702
// lambda_i = derive_interpolating_value(participant_list, identifier) | |
lambda, err := s.deriveInterpolatingValue(s.signerIndex, participants) | |
if err != nil { | |
// should never be the case for properly validated group commitments | |
return nil, err | |
} |
and validateGroupCommitments
would be the only function returning errors in Round2
. This wouldn't be 1:1 with the paper but this solution feels quite elegant to me.
What do you think about it?
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.
Regardless of the decision here, I added a test case to validateGroupCommitments
unit tests covering the duplicate element case: 1398d05.
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 think if we note in a comment that validateGroupCommitments
is a necessary part for checking the correctness, it should be fine.
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 will handle it in #8.
@@ -46,6 +46,9 @@ type Curve interface { | |||
// Identity returns elliptic curve identity element. | |||
Identity() *Point | |||
|
|||
// Order returns the order of the elliptic curve. | |||
Order() *big.Int |
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.
For some potential future implementations, this comment will need to be amended to "returns the order of the group produced by the generator". On some curves the generator produces a prime-order subgroup, whose order is not the same as that of the entire curve.
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.
That's a really good point. Improved in e1c912c.
On some curves the generator produces a prime-order subgroup, whose order is not the same as that of the entire curve.
Improved the test coverage to include the duplicate commitment case.
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.
Looks good.
// for x_j in L: | ||
// if count(x_j, L) > 1: | ||
// raise "invalid parameters" | ||
if found { |
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 think if we note in a comment that validateGroupCommitments
is a necessary part for checking the correctness, it should be fine.
deriveInterpolatingValue implements
def derive_interpolating_value(L, x_i)
function from [FROST], as defined in section 4.2 Polynomials.deriveInterpolatingValue is a simplified version of the algorithm for computing Lagrange coefficient given we only care about the value f(0) instead of reconstructing the entire polynomial.
L
is the list of the indices of the members of the particular group.xi
is the index of the participanti
.The function is identical as in @eth-r's prototype except that we return errors instead of panicking. Unit tests covering the function and explaining how interpolating value is calculated were added.