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

chore: genesis keygen doesn't rely on tests #1667

Merged
merged 3 commits into from
May 19, 2022
Merged

Conversation

msgmaxim
Copy link
Contributor

@msgmaxim msgmaxim commented May 17, 2022

Genesis keygen now works by calling the low level keygen functions to generate key shares instead of running a full ceremony (and thus relying on unit tests).

Notes for the reviewers:

  • compute_keygen_result is extracted out of compute_keygen_result_info without changes (it used to construct KeygenResultInfo by setting params and account id mapping, which I don't think belonged in that function);
  • generate_key_data should be of the most interest in this PR; it is the new function to be used to generate genesis keys;
  • finalize_keygen moved outside of detail namespace mostly unchanged (now it also assembles KeygenResultInfo from parts)
  • added genesis_keys_can_sign to verify that keyshares are generated correctly

Copy link
Contributor

@kylezs kylezs left a comment

Choose a reason for hiding this comment

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

Cheers for this, just some unused imports to remove it seems.

(
validator_map.get_id(idx).unwrap().clone(),
KeygenResultInfo {
key: compute_keygen_result(
Copy link
Contributor

Choose a reason for hiding this comment

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

You call derive_aggregate_pubkey inside this loop. I think it would be nicer to use the already generated one outside of the loop.

Copy link
Contributor

Choose a reason for hiding this comment

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

Will the result of derive_local_pubkeys_for_parties for each loop be the same? Could move that out as well, if so.

Copy link
Contributor Author

@msgmaxim msgmaxim May 18, 2022

Choose a reason for hiding this comment

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

compute_keygen_result procudes different keys for different parties (note that we give different shares to each party), so we can't take it outside of the loop.

Will the result of derive_local_pubkeys_for_parties for each loop be the same?

Yes, this particular value will be the same, but I prefer each party calling compute_keygen_result as this more closely resembles what parties do in a proper cermeony (rather than breaking it apart and creating more opportunities to diverge from ceremony code).

Copy link
Contributor

@AlastairHolmes AlastairHolmes May 18, 2022

Choose a reason for hiding this comment

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

I'd like to show you what the code could look like if #1671 and the above "move out of loop" where done. As I believe the code will be significantly cleaner, and allow more commonality to be factored out (Thereby actually decreasing the opportunities to diverge).

Thats why I suggested the change, so the checks that pubkey is "good", and be put/factored out into derive_aggregate_pubkey.

@AlastairHolmes
Copy link
Contributor

Should we use generate_key_data in the single_party_keygen?

@AlastairHolmes
Copy link
Contributor

AlastairHolmes commented May 17, 2022

I noticed we derive the pubkey in VerifyCommitmentsBroadcast2, but then we throw it away, and regenerate it at the final stage. Why do we do that? Wouldn't it be nicer to generate it once?

My problem with generating it twice is that we only check it is valid (contract compat etc) the first time, but not when we re-generate the key, which is confusing and dangerous IMO.

@msgmaxim
Copy link
Contributor Author

Should we use generate_key_data in the single_party_keygen?

Perhaps, but outside of scope. Note that generate_key_data deals with key shares, while signle party keygen does not. It is possible we can make it work with 1 share to get what we want, but I would need to play around with that idea first.

@msgmaxim
Copy link
Contributor Author

msgmaxim commented May 18, 2022

I noticed we derive the pubkey in VerifyCommitmentsBroadcast2, but then we throw it away

I'm assuming you talking about the ceremony code, and not the code contributed here. I don't particularly like having to send it all way through the stages, but you make a valid point, I will open an issue (#1671).

@AlastairHolmes
Copy link
Contributor

Should we use generate_key_data in the single_party_keygen?

Perhaps, but outside of scope. Note that generate_key_data deals with key shares, while signle party keygen does not. It is possible we can make it work with 1 share to get what we want, but I would need to play around with that idea first.

It seems to work for me. I'm not sure I understand your concern.

I do disagree its out of scope though. If you introduce a new method (in this case it is more general than the existing that only allows single partys) of doing something, I believe you should transition all existing code to use that method.

@msgmaxim msgmaxim merged commit 821609e into develop May 19, 2022
@msgmaxim msgmaxim deleted the feature/genesis-keygen branch May 19, 2022 03: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.

4 participants