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

[1.x] Externalize dependencies of process commit #219

Open
mulmarta opened this issue Nov 20, 2024 · 0 comments
Open

[1.x] Externalize dependencies of process commit #219

mulmarta opened this issue Nov 20, 2024 · 0 comments

Comments

@mulmarta
Copy link
Contributor

Background:

Part of #211

Before (0.x)

Process Commit API

// Make a key package store that conforms to the KeyPackageStorage trait
let psk_store = MyPskStore::new();

let client = Client::builder() 
        .pre_shared_key_storage(psk_store) // Transfer the ownership of the PSK repo to a client via the ClientBuilder
        ....
        .build();

// Load group from storage, transfer ownership of the PSK repo from client to group.
let group = client.load_group(group_id).unwrap();

// Process commit. Internally retrieves PSKs from the PSK repo
client.process_message(commit).unwrap();

After (1.x)

Process Commit API

let psk_store = MyPskStore::new();

let message_description = commit.description();

let MlsMessageDescription:: ProtocolMessage {
    group_id,
    epoch_id,
    content_type,
} = message_description
else {
    // Handle the case where this is not a protocol message
};

if content_type != ContentType::Commit {
    // Handle the case where this is not a Commit message
}

// Load group from storage. No PSK storage specific configuration.
let group_store = MyGroupStore::new();
let group_state = group_store.get(group_id, epoch_id).unwrap();
let mut group = Client:: resume_group(group_state).unwrap();

// Process commit. If commit is encrypted, this function decrypts it. This allows to access encrypted PSK IDs
let processor = group.commit_processor(commit).unwrap();

// Independently retrieve PSKs
let psks = psk_store.get(processor.psk_ids()).unwrap();

// Filter proposals
// Note to myself : processor should have validated that custom proposal types are supported
let filtered_proposals = my_proposal_filter(processor.proposals()).unwrap();

// Process the commit and transition group to new epoch.
processor
    .with_psks(psks)
    .with_proposals_override(filtered_proposals)
    .process()
    .unwrap();
struct CommitProcessor {
    group: &mut Group,
    decrypted_commit: AuthenticatedContent
}
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

No branches or pull requests

1 participant