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

Implemented deriveInterpolatingValue function #7

Merged
merged 3 commits into from
Dec 22, 2023
Merged

Implemented deriveInterpolatingValue function #7

merged 3 commits into from
Dec 22, 2023

Conversation

pdyraga
Copy link
Member

@pdyraga pdyraga commented Dec 21, 2023

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.

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.

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.
@pdyraga pdyraga requested a review from eth-r December 21, 2023 12:58
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.

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 {
Copy link
Contributor

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.

Copy link
Member Author

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:

roast-go/frost/signer.go

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?

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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
Copy link
Contributor

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.

Copy link
Member Author

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.
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.

// for x_j in L:
// if count(x_j, L) > 1:
// raise "invalid parameters"
if found {
Copy link
Contributor

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.

@eth-r eth-r merged commit 52d5838 into main Dec 22, 2023
2 checks passed
@eth-r eth-r deleted the polynomials branch December 22, 2023 14:23
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.

2 participants