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

feat: bootstrapping distributed key generation (stale) #632

Closed
wants to merge 16 commits into from

Conversation

djordon
Copy link
Contributor

@djordon djordon commented Oct 8, 2024

Description

Closes #590

Changes

  • Run DKG is we need to
  • Expect the public keys of the signers in the config. Not sure if this one will last.

There are still some things that need to be done,

  1. Submitting the rotate-keys transaction. Though I'm not entirely sure that we want to do that.
  2. Change the code to fallback on using the dkg_shares table for the current aggregate key if there is no rotate_keys_transaction in the database.

Testing Information

This also needs tests.

Checklist:

  • I have performed a self-review of my code
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@djordon djordon changed the title 590 bootstrapping distributed key generation feat: bootstrapping distributed key generation Oct 8, 2024
Copy link
Member

@cylewitruk cylewitruk 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, assuming that the actual logic in wsts_state_machine and wsts is correct :)

@@ -132,6 +132,17 @@ deployer = "SN2V7WTJ7BHR03MPHZ1C9A9ZR6NZGR4WM8HT4V67Y"
# Environment: SIGNER_SIGNER__DB_ENDPOINT
db_endpoint = "postgresql://postgres:postgres@localhost:5432/signer"

# The public keys of known signers who are approved to be in the signer
# set.
# The signer database endpoint (pgsql connection string)
Copy link
Member

Choose a reason for hiding this comment

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

Snuck in your copy-paste ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lol, 🙏🏽 thank you

#
# Required: true
# Environment: SIGNER_SIGNER__PEER_PUBLIC_KEYS
peer_public_keys = [
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, we should try to get rid of this for release, but for now is fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. I wasn't sure if we needed this for v1 or not (under the current design). I think the alternative is to have some other mechanism to get this information from their peers.

signer/src/error.rs Show resolved Hide resolved
signer/src/transaction_coordinator.rs Show resolved Hide resolved
Comment on lines 449 to 452
/// Check whether or not we need to run DKG
///
/// This function checks for the existence of a
/// [`RotateKeysTransaction`] in the database, and one does not exist
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Check whether or not we need to run DKG
///
/// This function checks for the existence of a
/// [`RotateKeysTransaction`] in the database, and one does not exist
/// Check whether or not we need to run DKG
///
/// This function first checks for the existence of a
/// [`RotateKeysTransaction`] row in the database. If one exists, then DKG
/// has already been completed.
///
/// If not, it then proceeds to check for DKG shares in the database for
/// the current signer aggregate key. If DKG shares exist but there is no
/// [`RotateKeysTransaction`] then one needs to be created, otherwise if
/// no shares exist then DKG needs to be run.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

perfect, yeah I forgot to update this.

@@ -553,6 +619,15 @@ where
PublicKey::from_private_key(&self.private_key)
}

/// This function provides a deterministic 32-byte identifier for the
/// signer. This should probably deterministically too.
Copy link
Member

Choose a reason for hiding this comment

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

"This should probably deterministically too" ... ? 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lol will update.

@@ -132,6 +132,17 @@ deployer = "SN2V7WTJ7BHR03MPHZ1C9A9ZR6NZGR4WM8HT4V67Y"
# Environment: SIGNER_SIGNER__DB_ENDPOINT
db_endpoint = "postgresql://postgres:postgres@localhost:5432/signer"

# The public keys of known signers who are approved to be in the signer
# set.
# The signer database endpoint (pgsql connection string)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: leftover line

signer/src/transaction_coordinator.rs Show resolved Hide resolved
@@ -169,6 +177,12 @@ where
.await?
.ok_or(Error::NoChainTip)?;

if self.needs_dkg(&bitcoin_chain_tip).await? == DkgState::NeedsDkg {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is not guarded by some self.is_coordinator condition, do we risk to have concurrent DKGs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I just forgot to add that in.

&mut self,
chain_tip: &model::BitcoinBlockHash,
) -> Result<PublicKey, Error> {
let mut state_machine = CoordinatorStateMachine::new([], self.threshold, self.private_key);
Copy link
Collaborator

Choose a reason for hiding this comment

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

sanity check: is the [ ] just a wip thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, forgot to change that.

@@ -553,6 +619,15 @@ where
PublicKey::from_private_key(&self.private_key)
}

/// This function provides a deterministic 32-byte identifier for the
/// signer. This should probably deterministically too.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: This should probably deterministically too I guess a word is missing somewhere, or is a repetition of the deterministic above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lol yeah typo.

along with the associated public key.
shares from the database, use in some key
places
@AshtonStephens AshtonStephens force-pushed the 590-bootstrapping-distributed-key-generation branch from 142823a to e4a2b7d Compare October 9, 2024 11:56
@djordon djordon force-pushed the 590-bootstrapping-distributed-key-generation branch from a5fa87d to 2c28d6e Compare October 9, 2024 13:35
@djordon djordon changed the title feat: bootstrapping distributed key generation feat: bootstrapping distributed key generation (stale) Oct 12, 2024
@djordon
Copy link
Contributor Author

djordon commented Oct 12, 2024

This has been superseded by #662 and #655.

@djordon djordon closed this Oct 12, 2024
@djordon djordon deleted the 590-bootstrapping-distributed-key-generation branch October 12, 2024 05:42
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.

[Feature]: Bootstrapping distributed key generation
3 participants