ts-mls
Version:
[](https://github.com/LukaJCB/ts-mls/actions/workflows/ci.yml) [](https://badge.fury.io/js/ts-mls) [) {
test(`3-party join ${cs}`, async () => {
await threePartyJoin(cs);
});
}
async function threePartyJoin(cipherSuite) {
const impl = await getCiphersuiteImpl(getCiphersuiteFromName(cipherSuite));
const aliceCredential = { credentialType: "basic", identity: new TextEncoder().encode("alice") };
const alice = await generateKeyPackage(aliceCredential, defaultCapabilities(), defaultLifetime, [], impl);
const groupId = new TextEncoder().encode("group1");
let aliceGroup = await createGroup(groupId, alice.publicPackage, alice.privatePackage, [], impl);
const bobCredential = { credentialType: "basic", identity: new TextEncoder().encode("bob") };
const bob = await generateKeyPackage(bobCredential, defaultCapabilities(), defaultLifetime, [], impl);
const charlieCredential = { credentialType: "basic", identity: new TextEncoder().encode("charlie") };
const charlie = await generateKeyPackage(charlieCredential, defaultCapabilities(), defaultLifetime, [], impl);
const addBobProposal = {
proposalType: "add",
add: {
keyPackage: bob.publicPackage,
},
};
const addBobCommitResult = await createCommit(aliceGroup, emptyPskIndex, false, [addBobProposal], impl);
aliceGroup = addBobCommitResult.newState;
let bobGroup = await joinGroup(addBobCommitResult.welcome, bob.publicPackage, bob.privatePackage, emptyPskIndex, impl, aliceGroup.ratchetTree);
expect(bobGroup.keySchedule.epochAuthenticator).toStrictEqual(aliceGroup.keySchedule.epochAuthenticator);
const addCharlieProposal = {
proposalType: "add",
add: {
keyPackage: charlie.publicPackage,
},
};
const addCharlieCommitResult = await createCommit(aliceGroup, emptyPskIndex, false, [addCharlieProposal], impl);
aliceGroup = addCharlieCommitResult.newState;
if (addCharlieCommitResult.commit.wireformat !== "mls_private_message")
throw new Error("Expected private message");
const processAddCharlieResult = await processPrivateMessage(bobGroup, addCharlieCommitResult.commit.privateMessage, makePskIndex(bobGroup, {}), impl);
bobGroup = processAddCharlieResult.newState;
expect(bobGroup.keySchedule.epochAuthenticator).toStrictEqual(aliceGroup.keySchedule.epochAuthenticator);
let charlieGroup = await joinGroup(addCharlieCommitResult.welcome, charlie.publicPackage, charlie.privatePackage, emptyPskIndex, impl, aliceGroup.ratchetTree);
expect(charlieGroup.keySchedule.epochAuthenticator).toStrictEqual(aliceGroup.keySchedule.epochAuthenticator);
await checkHpkeKeysMatch(aliceGroup, impl);
await checkHpkeKeysMatch(bobGroup, impl);
await checkHpkeKeysMatch(charlieGroup, impl);
await testEveryoneCanMessageEveryone([aliceGroup, bobGroup, charlieGroup], impl);
}
//# sourceMappingURL=threePartyJoin.test.js.map