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

Expose group ID and allow inspection #412

Merged
merged 10 commits into from
Dec 16, 2023
Merged

Expose group ID and allow inspection #412

merged 10 commits into from
Dec 16, 2023

Conversation

bifurcation
Copy link
Contributor

Right now, there is no way for application code to inspect an MLS message prior to handling it. PrivateMessages are of course encrypted until they are handled, but even PublicMessages hide the API to access the message contents. This PR makes such inspection possible, via an unwrap() method that produces AuthenticatedContent and a handle() variant that accepts AuthenticatedContent:

const auto content_auth = state.unwrap(message);
// Verify that content_auth has the right contents for the application context
const auto maybe_next = state.handle(content_auth);

As a convenience, we also expose group_id() on MLSMessage.

@bifurcation
Copy link
Contributor Author

A note while we're waiting for the CI to get fixed -- Having handle() accept AuthenticatedContent is sub-optimal, because it forces us to assume that content has been validated. Instead, we could encapsulate AuthenticatedContent in a wrapper type that would attest that the AuthenticatedContent had been validated. Something like:

struct ValidatedContent {
  private:
  // Only allow construction from outside friends that will validate
  AuthenticatedContent content_auth;
  ValidatedContent(AuthenticatedContent content_auth);
  friend struct PrivateMessage;
  friend struct PublicMessage;

  public:
  // Provide const / read-only access to the inner content
  const GroupContent& content() const;
};

@bifurcation bifurcation merged commit 97bd790 into main Dec 16, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants