ts-mls
Version:
[](https://github.com/LukaJCB/ts-mls/actions/workflows/ci.yml) [](https://badge.fury.io/js/ts-mls) [) {
test(`External join Resync ${cs}`, async () => {
await externalJoinResyncTest(cs);
});
}
async function externalJoinResyncTest(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 addCharlieProposal = {
proposalType: "add",
add: {
keyPackage: charlie.publicPackage,
},
};
const addBobAndCharlieCommitResult = await createCommit(aliceGroup, emptyPskIndex, false, [addBobProposal, addCharlieProposal], impl, true);
aliceGroup = addBobAndCharlieCommitResult.newState;
let bobGroup = await joinGroup(addBobAndCharlieCommitResult.welcome, bob.publicPackage, bob.privatePackage, emptyPskIndex, impl);
expect(bobGroup.keySchedule.epochAuthenticator).toStrictEqual(aliceGroup.keySchedule.epochAuthenticator);
let charlieGroup = await joinGroup(addBobAndCharlieCommitResult.welcome, charlie.publicPackage, charlie.privatePackage, emptyPskIndex, impl);
expect(charlieGroup.keySchedule.epochAuthenticator).toStrictEqual(aliceGroup.keySchedule.epochAuthenticator);
const groupInfo = await createGroupInfoWithExternalPubAndRatchetTree(charlieGroup, impl);
const charlieResyncCommitResult = await joinGroupExternal(groupInfo, charlie.publicPackage, charlie.privatePackage, true, impl);
charlieGroup = charlieResyncCommitResult.newState;
const aliceProcessCharlieResyncResult = await processPublicMessage(aliceGroup, charlieResyncCommitResult.publicMessage, makePskIndex(aliceGroup, {}), impl);
aliceGroup = aliceProcessCharlieResyncResult.newState;
const bobProcessCharlieResyncResult = await processPublicMessage(bobGroup, charlieResyncCommitResult.publicMessage, makePskIndex(bobGroup, {}), impl);
bobGroup = bobProcessCharlieResyncResult.newState;
expect(charlieGroup.keySchedule.epochAuthenticator).toStrictEqual(aliceGroup.keySchedule.epochAuthenticator);
expect(charlieGroup.keySchedule.epochAuthenticator).toStrictEqual(bobGroup.keySchedule.epochAuthenticator);
await checkHpkeKeysMatch(aliceGroup, impl);
await checkHpkeKeysMatch(bobGroup, impl);
await checkHpkeKeysMatch(charlieGroup, impl);
await testEveryoneCanMessageEveryone([aliceGroup, bobGroup, charlieGroup], impl);
}
//# sourceMappingURL=externalJoinResync.test.js.map