ts-mls
Version:
[](https://github.com/LukaJCB/ts-mls/actions/workflows/ci.yml) [](https://badge.fury.io/js/ts-mls) [ => idx !== 2).entries()) {
test(`tree-operations test vectors ${index}`, async () => {
const impl = await getCiphersuiteImpl(getCiphersuiteFromId(x.cipher_suite));
await treeOperationsTest(x, impl);
});
}
async function treeOperationsTest(data, impl) {
const tree = decodeRatchetTree(hexToBytes(data.tree_before), 0);
if (tree === undefined)
throw new Error("could not decode tree");
const hash = await treeHashRoot(tree[0], impl.hash);
expect(hash).toStrictEqual(hexToBytes(data.tree_hash_before));
const proposal = decodeProposal(hexToBytes(data.proposal), 0);
if (proposal === undefined)
throw new Error("could not decode proposal");
const treeAfter = applyProposal(proposal[0], tree[0], data);
if (treeAfter === undefined)
throw new Error("Could not apply proposal: " + proposal[0].proposalType);
expect(encodeRatchetTree(treeAfter)).toStrictEqual(hexToBytes(data.tree_after));
const hashAfter = await treeHashRoot(treeAfter, impl.hash);
expect(hashAfter).toStrictEqual(hexToBytes(data.tree_hash_after));
}
function applyProposal(proposal, tree, data) {
switch (proposal.proposalType) {
case "add":
return addLeafNode(tree, proposal.add.keyPackage.leafNode)[0];
case "update":
return updateLeafNode(tree, proposal.update.leafNode, data.proposal_sender);
case "remove":
return removeLeafNode(tree, proposal.remove.removed);
case "psk":
case "reinit":
case "external_init":
case "group_context_extensions":
}
}
//# sourceMappingURL=treeOperations.test.js.map