Skip to content

Commit

Permalink
ensure deterministic reshard input
Browse files Browse the repository at this point in the history
  • Loading branch information
emostov committed Apr 21, 2024
1 parent 69c006d commit 54f8ab5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/qos_client/src/cli/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,8 @@ pub(crate) fn reshard_re_encrypt_share(
unsafe_auto_confirm,
}: ReshardReEncryptShareArgs,
) -> Result<(), Error> {
let reshard_input = read_reshard_input(reshard_input_path)?;
let mut reshard_input = read_reshard_input(reshard_input_path)?;
reshard_input.deterministic();
let attestation_doc =
read_attestation_doc(&attestation_doc_path, unsafe_skip_attestation)?;
let mut new_share_set = get_share_set(&new_share_set_dir);
Expand Down
3 changes: 2 additions & 1 deletion src/qos_core/src/protocol/services/attestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ pub(in crate::protocol) fn reshard_attestation_doc(
) -> Result<NsmResponse, ProtocolError> {
let ephemeral_public_key =
state.handles.get_ephemeral_key()?.public_key().to_bytes();
let reshard_input = state
let mut reshard_input = state
.reshard_input
.clone()
.ok_or(ProtocolError::MissingReshardInput)?;
reshard_input.deterministic();

Ok(get_post_boot_attestation_doc(
&*state.attestor,
Expand Down
6 changes: 4 additions & 2 deletions src/qos_core/src/protocol/services/reshard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ pub struct ReshardInput {
}

impl ReshardInput {
fn deterministic(&mut self) {
/// Make sure reshard input is deterministic
pub fn deterministic(&mut self) {
self.quorum_keys.sort();
}

Expand Down Expand Up @@ -249,12 +250,13 @@ pub(in crate::protocol) fn reshard_provision(
input: ReshardProvisionInput,
state: &mut ProtocolState,
) -> Result<bool, ProtocolError> {
let reshard_input = state
let mut reshard_input = state
.reshard_input
.as_ref()
.ok_or(ProtocolError::MissingReshardInput)?
.clone();

reshard_input.deterministic();
input.approval.verify(&reshard_input.qos_hash())?;

if !reshard_input.old_share_set.members.contains(&input.approval.member) {
Expand Down

0 comments on commit 54f8ab5

Please sign in to comment.