-
Notifications
You must be signed in to change notification settings - Fork 3
feat: initial tss crate integration #604
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,10 +13,12 @@ use crate::protocol::state::{PersistentNodeData, WaitingForConsensusState}; | |
| use crate::protocol::MeshState; | ||
| use crate::types::{ReshareProtocol, SecretKeyShare}; | ||
|
|
||
| use cait_sith::protocol::{Action, InitializationError, Participant, ProtocolError}; | ||
| use k256::elliptic_curve::group::GroupEncoding; | ||
| use k256::elliptic_curve::sec1::ToEncodedPoint; | ||
| use k256::sha2::{Digest, Sha256}; | ||
| use mpc_crypto::PublicKey; | ||
| use threshold_signatures::errors::{InitializationError, ProtocolError}; | ||
| use threshold_signatures::participants::Participant; | ||
| use threshold_signatures::protocol::Action; | ||
| use tokio::sync::mpsc; | ||
|
|
||
| pub static RESHARING_RUNNING_TIMEOUT_SECS: AtomicU64 = AtomicU64::new(300); | ||
|
|
@@ -31,10 +33,10 @@ pub fn set_resharing_running_timeout(duration: Duration) { | |
|
|
||
| #[derive(thiserror::Error, Debug)] | ||
| pub enum CryptographicError { | ||
| #[error("cait-sith initialization error: {0}")] | ||
| CaitSithInitializationError(#[from] InitializationError), | ||
| #[error("cait-sith protocol error: {0}")] | ||
| CaitSithProtocolError(#[from] ProtocolError), | ||
| #[error("initialization error: {0}")] | ||
| Init(#[from] InitializationError), | ||
| #[error("protocol error: {0}")] | ||
| Protocol(#[from] ProtocolError), | ||
| } | ||
|
|
||
| pub(crate) trait CryptographicProtocol { | ||
|
|
@@ -93,7 +95,7 @@ impl CryptographicProtocol for GeneratingState { | |
| tracing::debug!("generating: sending a message to many participants"); | ||
| for p in &participants { | ||
| if p == &self.me { | ||
| // Skip yourself, cait-sith never sends messages to oneself | ||
| // Skip yourself, threshold-signatures never sends messages to oneself | ||
| continue; | ||
| } | ||
|
|
||
|
|
@@ -124,10 +126,19 @@ impl CryptographicProtocol for GeneratingState { | |
| } | ||
| Action::Return(r) => { | ||
| tracing::info!( | ||
| public_key = hex::encode(r.public_key.to_bytes()), | ||
| public_key = hex::encode( | ||
| r.public_key | ||
| .to_element() | ||
| .to_affine() | ||
| .to_encoded_point(true) | ||
| .as_bytes() | ||
| ), | ||
| "generating: successfully completed key generation" | ||
| ); | ||
| return self.finalize(r.public_key, r.private_share, ctx).await; | ||
| // Convert frost_core::VerifyingKey -> AffinePoint for storage | ||
| return self | ||
| .finalize(r.public_key.to_element().to_affine(), r.private_share, ctx) | ||
| .await; | ||
|
Comment on lines
+138
to
+141
|
||
| } | ||
| } | ||
| } | ||
|
|
@@ -344,11 +355,16 @@ impl CryptographicProtocol for ResharingState { | |
| .await; | ||
| } | ||
| } | ||
| Action::Return(private_share) => { | ||
| Action::Return(keygen_output) => { | ||
| tracing::info!("resharing: successfully completed key reshare"); | ||
| resharing.last_activity = Instant::now(); | ||
| match Self::try_finalize(ctx, &mut resharing, private_share, &self.contract) | ||
| .await | ||
| match Self::try_finalize( | ||
| ctx, | ||
| &mut resharing, | ||
| keygen_output.private_share, | ||
| &self.contract, | ||
| ) | ||
| .await | ||
| { | ||
| Ok(next_state) => return next_state, | ||
| Err(()) => { | ||
|
|
||
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.
[nitpick] Added fallback to
old_participantswhen looking up participant info during resharing. This change on line 176 ensures that nodes in the old participant set (but not in the new set) can still find their participant info. This is a good fix, but verify that this doesn't cause issues if a participant exists in both old and new sets with different info.