Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
6 changes: 6 additions & 0 deletions bin/orbis-node/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ pub const DEFAULT_RESHARE_INTERVAL_SECS: u64 = 60 * 60;
/// the intended interval rather than up to check_interval seconds late.
pub const PSS_GRACE_PERIOD_SECS: u64 = 10;

/// Maximum number of attempts to collect threshold signatures at the end of a reshare.
pub const RESHARE_SIGNATURE_MAX_ATTEMPTS: usize = 6;

/// Delay between reshare threshold signature collection retries.
pub const RESHARE_SIGNATURE_RETRY_DELAY: Duration = Duration::from_millis(500);

// ============================================================================
// Nonce Serialization Constants (FROST)
// ============================================================================
Expand Down
59 changes: 44 additions & 15 deletions bin/orbis-node/src/dkg/coordinator/message_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ use authn::{resolve_jwt_did, BearerToken, DkgClaims};
use crypto::r#trait::{DistributedShare, Dkg, DkgRole};
use crypto::{
CryptoDeserialize, GroupAffine as G1Affine, PolynomialCommitmentImpl as PolynomialCommitment,
ScalarField as Fr, GROUP_POINT_SIZE as G1_COMPRESSED_SIZE, SCALAR_SIZE as FR_COMPRESSED_SIZE,
PubPolyImpl as PubPoly, ScalarField as Fr, GROUP_POINT_SIZE as G1_COMPRESSED_SIZE,
SCALAR_SIZE as FR_COMPRESSED_SIZE,
};
use network::PeerId;
use std::collections::{HashMap, HashSet};
Expand Down Expand Up @@ -55,8 +56,12 @@ pub(super) async fn handle_session_init<D>(
sender_peer_id: &PeerId,
) -> Result<Option<DkgMessage>>
where
D: Dkg<ShareValue = Fr, PublicKey = G1Affine, PolynomialCommitment = PolynomialCommitment>
+ Clone
D: Dkg<
ShareValue = Fr,
PublicKey = G1Affine,
PolynomialCommitment = PolynomialCommitment,
PubPoly = PubPoly,
> + Clone
+ 'static,
{
let sender_hex = hex::encode(sender_peer_id.as_bytes());
Expand Down Expand Up @@ -525,8 +530,12 @@ pub(super) async fn handle_commitment_message<D>(
commitment: Vec<u8>,
) -> Result<Option<DkgMessage>>
where
D: Dkg<ShareValue = Fr, PublicKey = G1Affine, PolynomialCommitment = PolynomialCommitment>
+ Clone
D: Dkg<
ShareValue = Fr,
PublicKey = G1Affine,
PolynomialCommitment = PolynomialCommitment,
PubPoly = PubPoly,
> + Clone
+ 'static,
{
tracing::debug!(
Expand Down Expand Up @@ -781,8 +790,12 @@ pub(super) async fn handle_share_message<D>(
nonce: [u8; 16],
) -> Result<Option<DkgMessage>>
where
D: Dkg<ShareValue = Fr, PublicKey = G1Affine, PolynomialCommitment = PolynomialCommitment>
+ Clone
D: Dkg<
ShareValue = Fr,
PublicKey = G1Affine,
PolynomialCommitment = PolynomialCommitment,
PubPoly = PubPoly,
> + Clone
+ 'static,
{
if share_value.is_empty() {
Expand Down Expand Up @@ -907,8 +920,12 @@ pub(super) async fn record_and_ack_valid_reshare_share<D>(
dealer_id: u32,
) -> Result<()>
where
D: Dkg<ShareValue = Fr, PublicKey = G1Affine, PolynomialCommitment = PolynomialCommitment>
+ Clone
D: Dkg<
ShareValue = Fr,
PublicKey = G1Affine,
PolynomialCommitment = PolynomialCommitment,
PubPoly = PubPoly,
> + Clone
+ 'static,
{
let ack = coord
Expand Down Expand Up @@ -988,8 +1005,12 @@ pub(super) async fn handle_reshare_share_ack<D>(
dealer_id: u32,
) -> Result<Option<DkgMessage>>
where
D: Dkg<ShareValue = Fr, PublicKey = G1Affine, PolynomialCommitment = PolynomialCommitment>
+ Clone
D: Dkg<
ShareValue = Fr,
PublicKey = G1Affine,
PolynomialCommitment = PolynomialCommitment,
PubPoly = PubPoly,
> + Clone
+ 'static,
{
let selection = coord
Expand Down Expand Up @@ -1102,8 +1123,12 @@ async fn broadcast_reshare_participant_set<D>(
new_peer_ids: &[String],
) -> Result<()>
where
D: Dkg<ShareValue = Fr, PublicKey = G1Affine, PolynomialCommitment = PolynomialCommitment>
+ Clone
D: Dkg<
ShareValue = Fr,
PublicKey = G1Affine,
PolynomialCommitment = PolynomialCommitment,
PubPoly = PubPoly,
> + Clone
+ 'static,
{
let mut failures = Vec::new();
Expand Down Expand Up @@ -1169,8 +1194,12 @@ pub(super) async fn handle_reshare_participant_set<D>(
selected_dealer_ids: Vec<u32>,
) -> Result<Option<DkgMessage>>
where
D: Dkg<ShareValue = Fr, PublicKey = G1Affine, PolynomialCommitment = PolynomialCommitment>
+ Clone
D: Dkg<
ShareValue = Fr,
PublicKey = G1Affine,
PolynomialCommitment = PolynomialCommitment,
PubPoly = PubPoly,
> + Clone
+ 'static,
{
let accepted = coord
Expand Down
11 changes: 8 additions & 3 deletions bin/orbis-node/src/dkg/coordinator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ use crate::metrics;
use ::network::PeerId;
use crypto::r#trait::{Dkg, DkgRole};
use crypto::{
GroupAffine as G1Affine, PolynomialCommitmentImpl as PolynomialCommitment, ScalarField as Fr,
GroupAffine as G1Affine, PolynomialCommitmentImpl as PolynomialCommitment,
PubPolyImpl as PubPoly, ScalarField as Fr,
};
use std::sync::Arc;

Expand All @@ -55,8 +56,12 @@ where

impl<D> DkgCoordinator<D>
where
D: Dkg<ShareValue = Fr, PublicKey = G1Affine, PolynomialCommitment = PolynomialCommitment>
+ Clone
D: Dkg<
ShareValue = Fr,
PublicKey = G1Affine,
PolynomialCommitment = PolynomialCommitment,
PubPoly = PubPoly,
> + Clone
+ 'static,
{
/// Create a new DKG session manager for this node.
Expand Down
35 changes: 26 additions & 9 deletions bin/orbis-node/src/dkg/coordinator/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use crate::dkg::messages::DkgMessage;
use crate::metrics;
use crypto::r#trait::Dkg;
use crypto::{
GroupAffine as G1Affine, PolynomialCommitmentImpl as PolynomialCommitment, ScalarField as Fr,
GroupAffine as G1Affine, PolynomialCommitmentImpl as PolynomialCommitment,
PubPolyImpl as PubPoly, ScalarField as Fr,
};
use network::{Connection as NetworkConnection, Message as NetworkMessage, DKG};
use std::sync::Arc;
Expand All @@ -30,8 +31,12 @@ async fn get_cached_or_open_stream<D>(
peer_id_str: &str,
) -> Result<(Arc<dyn NetworkConnection>, bool)>
where
D: Dkg<ShareValue = Fr, PublicKey = G1Affine, PolynomialCommitment = PolynomialCommitment>
+ Clone
D: Dkg<
ShareValue = Fr,
PublicKey = G1Affine,
PolynomialCommitment = PolynomialCommitment,
PubPoly = PubPoly,
> + Clone
+ 'static,
{
if let Some(cached) = coord
Expand All @@ -55,8 +60,12 @@ async fn ensure_session_generation<D>(
generation: u64,
) -> Result<()>
where
D: Dkg<ShareValue = Fr, PublicKey = G1Affine, PolynomialCommitment = PolynomialCommitment>
+ Clone
D: Dkg<
ShareValue = Fr,
PublicKey = G1Affine,
PolynomialCommitment = PolynomialCommitment,
PubPoly = PubPoly,
> + Clone
+ 'static,
{
if coord
Expand Down Expand Up @@ -89,8 +98,12 @@ pub(super) async fn send_message_to_peer<D>(
session_id: Option<u64>,
) -> Result<()>
where
D: Dkg<ShareValue = Fr, PublicKey = G1Affine, PolynomialCommitment = PolynomialCommitment>
+ Clone
D: Dkg<
ShareValue = Fr,
PublicKey = G1Affine,
PolynomialCommitment = PolynomialCommitment,
PubPoly = PubPoly,
> + Clone
+ 'static,
{
let message_type = match &message {
Expand Down Expand Up @@ -185,8 +198,12 @@ pub(super) async fn open_stream_to_peer<D>(
peer_id_str: &str,
) -> Result<Box<dyn network::Connection>>
where
D: Dkg<ShareValue = Fr, PublicKey = G1Affine, PolynomialCommitment = PolynomialCommitment>
+ Clone
D: Dkg<
ShareValue = Fr,
PublicKey = G1Affine,
PolynomialCommitment = PolynomialCommitment,
PubPoly = PubPoly,
> + Clone
+ 'static,
{
coord
Expand Down
Loading
Loading