ts-mls
Version:
[](https://github.com/LukaJCB/ts-mls/actions/workflows/ci.yml) [](https://badge.fury.io/js/ts-mls) [) {
test(`tree-validation 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), 0);
if (tree === undefined)
throw new Error("could not decode tree");
for (const [i, h] of data.tree_hashes.entries()) {
const hash = await treeHash(tree[0], i, impl.hash);
expect(hash).toStrictEqual(hexToBytes(h));
}
for (const [i, r] of data.resolutions.entries()) {
const reso = resolution(tree[0], i);
expect(reso).toStrictEqual(r);
}
expect(await verifyParentHashes(tree[0], impl.hash)).toBe(true);
for (const [i, n] of tree[0].entries()) {
if (n !== undefined) {
if (n.nodeType === "leaf") {
expect(await verifyLeafNodeSignature(n.leaf, hexToBytes(data.group_id), nodeToLeafIndex(i), impl.signature)).toBe(true);
}
}
}
}
//# sourceMappingURL=treeValidation.test.js.map