ts-mls
Version:
[](https://github.com/LukaJCB/ts-mls/actions/workflows/ci.yml) [](https://badge.fury.io/js/ts-mls) [) {
test("should reject structurally unsound ratchet tree", async () => {
await testStructuralIntegrity(cs);
});
}
async function testStructuralIntegrity(cipherSuite) {
const impl = await getCiphersuiteImpl(getCiphersuiteFromName(cipherSuite));
const aliceCredential = { credentialType: "basic", identity: new TextEncoder().encode("alice") };
const aliceCapabilities = {
extensions: [],
credentials: ["basic"],
proposals: [],
versions: ["mls10"],
ciphersuites: [cipherSuite],
};
const alice = await generateKeyPackage(aliceCredential, aliceCapabilities, defaultLifetime, [], impl);
const validLeafNode = alice.publicPackage.leafNode;
// Make the first node a parent node, which is invalid for a leaf position
const invalidTree = [
{
nodeType: "parent",
parent: {
unmergedLeaves: [],
parentHash: new Uint8Array(),
hpkePublicKey: new Uint8Array(),
},
},
{ nodeType: "leaf", leaf: validLeafNode },
{ nodeType: "leaf", leaf: validLeafNode },
];
const groupContext = {
version: "mls10",
cipherSuite: cipherSuite,
epoch: 0n,
treeHash: new Uint8Array(),
groupId: new Uint8Array(),
extensions: [],
confirmedTranscriptHash: new Uint8Array(),
};
const error = await validateRatchetTree(invalidTree, groupContext, defaultLifetimeConfig, defaultAuthenticationService, new Uint8Array(), impl);
expect(error).toBeInstanceOf(ValidationError);
expect(error?.message).toBe("Received Ratchet Tree is not structurally sound");
}
//# sourceMappingURL=ratchetTreeValidation.test.js.map