Skip to content

sub group branching with new group builder#1913

Draft
franziskuskiefer wants to merge 1 commit intomainfrom
franziskus/sub-groups
Draft

sub group branching with new group builder#1913
franziskuskiefer wants to merge 1 commit intomainfrom
franziskus/sub-groups

Conversation

@franziskuskiefer
Copy link
Contributor

We shouldn't just add another way of processing welcomes (it's also not done all the way right now). Moving to a builder style like for the commits makes sense to me. Also for other things like #1843. This is for discussion and we should decide on the style we want to support going forward.

cc @keks

Copy link
Contributor

@keks keks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some early feedback. I think this PR is doing a lot, and maybe we can talk offline about the bigger approach here, which builders are responsible for what, etc.

Comment on lines +260 to +285
/// Adds a PreSharedKey proposal for the provided [`PreSharedKeyId`]s to the
/// list of proposals to be committed.
///
/// Note that this should not be used for sub-group branching, as those PSKs
/// are not allowed in regular proposals. Please use [`Self::branch()`] instead.
pub fn propose_psks(mut self, psk_ids: impl IntoIterator<Item = PreSharedKeyId>) -> Self {
self.stage.own_proposals.extend(
psk_ids
.into_iter()
.map(|psk_id| Proposal::psk(PreSharedKeyProposal::new(psk_id))),
);
self
}

/// Branches the group by adding a branch PreSharedKey proposals.
pub fn branch(mut self, psk_id: PreSharedKeyId, secret: ResumptionPskSecret) -> Self {
self = self.propose_psks([psk_id]);

// We clear the resumption PSK store first and then add the branching PSK.
self.group.borrow_mut().resumption_psk_store.clear();
self.group
.borrow_mut()
.resumption_psk_store
.add(0.into(), secret);
self
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these already check that the PSKs are suitable for the use case and do not contradict?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it could ... but we need the check later again because more psks may have been added after this. So I'm not sure if checking here gives us so much.

Comment on lines +379 to +399
/// Adds a PreSharedKey proposal for the provided [`PreSharedKeyId`]s to the list of proposals
/// to be committed.
///
/// Note that this should not be used for sub-group branching, as those PSKs
/// are not allowed in regular proposals. Please use [`Self::branch()`] instead.
pub fn propose_psks(mut self, psk_ids: impl IntoIterator<Item = PreSharedKeyId>) -> Self {
self.stage.own_proposals.extend(
psk_ids
.into_iter()
.map(|psk_id| Proposal::psk(PreSharedKeyProposal::new(psk_id))),
);
self
}

/// Branches the group by adding a branch PreSharedKey proposals.
pub fn branch(mut self, psk_id: PreSharedKeyId) -> Self {
self.stage.branch = true;
self = self.propose_psks([psk_id]);
self
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these should be here. The LoadedPsk phase is too late to add more proposals, especially PSK proposals, because then these are not loaded anymore and the later computations won't have the keys (just the IDs).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, this bit shouldn't be here.


/// The state after decrypting the group secrets in the welcome message.
pub struct Decrypted<'a> {
/// The initial state.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The initial state.
/// The previous state.


/// The state after loading and generating the PSK secret.
pub struct Psks<'a> {
/// The initial state.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The initial state.
/// The previous state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants