Skip to content
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
3 changes: 3 additions & 0 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions bootstore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ use serde::{Deserialize, Serialize};
Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize,
)]
pub struct Sha3_256Digest([u8; 32]);

impl Sha3_256Digest {
pub fn new(bytes: [u8; 32]) -> Self {
Sha3_256Digest(bytes)
}
}
1 change: 0 additions & 1 deletion bootstore/src/trust_quorum/rack_secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ impl RackSecret {
}

/// Combine a set of shares and return a RackSecret
#[allow(unused)]
pub fn combine_shares(
shares: &[Vec<u8>],
) -> Result<RackSecret, vsss_rs::Error> {
Expand Down
29 changes: 18 additions & 11 deletions trust-quorum/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//! A configuration of a trust quroum at a given epoch

use crate::crypto::{EncryptedRackSecrets, RackSecret, Sha3_256Digest};
use crate::validators::ValidatedReconfigureMsg;
use crate::{Epoch, PlatformId, Threshold};
use daft::Diffable;
use gfss::shamir::{Share, SplitError};
Expand All @@ -15,7 +14,7 @@ use secrecy::ExposeSecret;
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
use slog_error_chain::SlogInlineError;
use std::collections::BTreeMap;
use std::collections::{BTreeMap, BTreeSet};

#[derive(Debug, Clone, thiserror::Error, PartialEq, Eq, SlogInlineError)]
pub enum ConfigurationError {
Expand Down Expand Up @@ -75,22 +74,30 @@ impl IdOrdItem for Configuration {
id_upcast!();
}

pub struct NewConfigParams<'a> {
pub rack_id: RackUuid,
pub epoch: Epoch,
pub members: &'a BTreeSet<PlatformId>,
pub threshold: Threshold,
pub coordinator_id: &'a PlatformId,
}

impl Configuration {
/// Create a new configuration for the trust quorum
///
/// `previous_configuration` is never filled in upon construction. A
/// coordinator will fill this in as necessary after retrieving shares for
/// the last committed epoch.
pub fn new(
reconfigure_msg: &ValidatedReconfigureMsg,
params: NewConfigParams<'_>,
) -> Result<(Configuration, BTreeMap<PlatformId, Share>), ConfigurationError>
{
let coordinator = reconfigure_msg.coordinator_id().clone();
let coordinator = params.coordinator_id.clone();
let rack_secret = RackSecret::new();
let shares = rack_secret.split(
reconfigure_msg.threshold(),
reconfigure_msg
.members()
params.threshold,
params
.members
.len()
.try_into()
.map_err(|_| ConfigurationError::TooManyMembers)?,
Expand All @@ -106,19 +113,19 @@ impl Configuration {
let mut members: BTreeMap<PlatformId, Sha3_256Digest> = BTreeMap::new();
let mut shares: BTreeMap<PlatformId, Share> = BTreeMap::new();
for (platform_id, (share, digest)) in
reconfigure_msg.members().iter().cloned().zip(shares_and_digests)
params.members.iter().cloned().zip(shares_and_digests)
{
members.insert(platform_id.clone(), digest);
shares.insert(platform_id, share);
}

Ok((
Configuration {
rack_id: reconfigure_msg.rack_id(),
epoch: reconfigure_msg.epoch(),
rack_id: params.rack_id,
epoch: params.epoch,
coordinator,
members,
threshold: reconfigure_msg.threshold(),
threshold: params.threshold,
encrypted_rack_secrets: None,
},
shares,
Expand Down
Loading
Loading