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: bump wsts revision #1262

Merged
merged 4 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions protobufs/crypto/wsts/wsts.proto
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ message DkgStatus {
MissingPrivateShares missing_private_shares = 5;
// DKG private shares were bad from these signer_ids
BadPrivateShares bad_private_shares = 6;
// The DKG threshold was not met
Threshold threshold = 7;
}
}

Expand Down Expand Up @@ -318,3 +320,6 @@ message SignatureShare {
// The key IDs of the party
repeated uint32 key_ids = 3;
}

// The DKG threshold has not been upheld by the coordinator.
message Threshold {}
2 changes: 1 addition & 1 deletion signer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ tracing-attributes.workspace = true
tracing-subscriber = { workspace = true }
url.workspace = true
# wsts.workspace = true
wsts = { git = "https://github.com/Trust-Machines/wsts.git", rev = "b7c009e4903bcf03351847a9341c25a26d36c042" }
wsts = { git = "https://github.com/Trust-Machines/wsts.git", rev = "53ae23f5f35def420877ccc8c0fe3662e64e38a1" }
hex.workspace = true
cfg-if = "1.0"
include_dir = "0.7.4"
Expand Down
2 changes: 2 additions & 0 deletions signer/src/proto/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,7 @@ impl From<DkgStatus> for proto::DkgStatus {
DkgFailure::BadPrivateShares(inner) => {
proto::dkg_status::Mode::BadPrivateShares(inner.into())
}
DkgFailure::Threshold => proto::dkg_status::Mode::Threshold(proto::Threshold {}),
},
};
proto::DkgStatus { mode: Some(mode) }
Expand All @@ -828,6 +829,7 @@ impl TryFrom<proto::DkgStatus> for DkgStatus {
proto::dkg_status::Mode::BadPrivateShares(inner) => {
DkgStatus::Failure(DkgFailure::BadPrivateShares(inner.try_into()?))
}
proto::dkg_status::Mode::Threshold(_) => DkgStatus::Failure(DkgFailure::Threshold),
})
}
}
Expand Down
9 changes: 8 additions & 1 deletion signer/src/proto/generated/crypto.wsts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ pub struct ProofIdentifier {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DkgStatus {
#[prost(oneof = "dkg_status::Mode", tags = "1, 2, 3, 4, 5, 6")]
#[prost(oneof = "dkg_status::Mode", tags = "1, 2, 3, 4, 5, 6, 7")]
pub mode: ::core::option::Option<dkg_status::Mode>,
}
/// Nested message and enum types in `DkgStatus`.
Expand All @@ -399,6 +399,9 @@ pub mod dkg_status {
/// DKG private shares were bad from these signer_ids
#[prost(message, tag = "6")]
BadPrivateShares(super::BadPrivateShares),
/// The DKG threshold was not met
#[prost(message, tag = "7")]
Threshold(super::Threshold),
}
}
/// DKG completed successfully
Expand Down Expand Up @@ -514,3 +517,7 @@ pub struct SignatureShare {
#[prost(uint32, repeated, tag = "3")]
pub key_ids: ::prost::alloc::vec::Vec<u32>,
}
/// The DKG threshold has not been upheld by the coordinator.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Threshold {}
21 changes: 19 additions & 2 deletions signer/src/wsts_state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use crate::storage::model;
use crate::storage::model::SigHash;

use bitcoin::hashes::Hash as _;
use hashbrown::HashMap;
use hashbrown::HashSet;
use wsts::common::PolyCommitment;
use wsts::state_machine::coordinator::Coordinator as _;
use wsts::state_machine::coordinator::State as WstsState;
Expand Down Expand Up @@ -81,6 +83,7 @@ impl SignerStateMachine {
.try_into()
.map_err(|_| error::Error::TypeConversion)?;
let num_keys = num_parties;
let dkg_threshold = num_parties;

let p256k1_public_key = p256k1::keys::PublicKey::from(&signer_pub_key);
let id: u32 = *signers
Expand All @@ -89,7 +92,19 @@ impl SignerStateMachine {
.ok_or_else(|| error::Error::MissingPublicKey)?
.0;

let public_keys = wsts::state_machine::PublicKeys { signers, key_ids };
let signer_key_ids: HashMap<u32, HashSet<u32>> = signers
.iter()
.map(|(&signer_id, _)| {
let mut keys = HashSet::new();
keys.insert(signer_id + 1);
(signer_id, keys)
})
.collect();
let public_keys = wsts::state_machine::PublicKeys {
signers,
key_ids,
signer_key_ids,
};

let key_ids = vec![id + 1];

Expand All @@ -99,13 +114,15 @@ impl SignerStateMachine {

let state_machine = WstsStateMachine::new(
threshold,
dkg_threshold,
num_parties,
num_keys,
id,
key_ids,
signer_private_key.into(),
public_keys,
);
)
.map_err(Error::Wsts)?;

Ok(Self(state_machine))
}
Expand Down
Loading