// Generate Signature KeyPairs for Alice and Bob
let alice = await mls.generateIdentity();
let bob = await mls.generateIdentity();
// Generate Credentials for Alice and Bob
let credential_alice = await mls.generateCredential("alice");
let credential_bob = await mls.generateCredential("bob");
// Generate a KeyPackage for Bob
let kp_bob = await mls.generateKeyPackage(bob, credential_bob);
// Creation of a Group by Alice
let group_alice = await mls.groupCreate(alice, credential_alice);
// Alice adds Bob to a group
let commit_output = await group_alice.add(kp_bob);
// Test: the returned commit output is not null
info("Commit Output 1:", JSON.stringify(commit_output));
isnot(JSON.stringify(commit_output), "", "Commit Output != ''");
// Alice receives the commit
let group_and_epoch_1_alice = await group_alice.receive(commit_output.commit);
// Info: the new group identifier and epoch are valid
info("Alice Group Identifier and Epoch:", JSON.stringify(group_and_epoch_1_alice));
// Bob joins the group
let group_bob = await mls.groupJoin(bob, commit_output.welcome);
// Test: compare the group identifier after the join
is(byteArrayToHexString(group_alice.groupId), byteArrayToHexString(group_bob.groupId), "Alice GID == Bob GID");
// Bob sends a message to Alice
const message = new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 32, 33]); // "Hello World !" in ASCII
let ciphertext_bytes = await group_bob.send(message);
// Alice decrypts the message from Bob
let received_message = await group_alice.receive(ciphertext_bytes);
// Test: compare the generated group identifier to incorrect values
is(byteArrayToHexString(message), byteArrayToHexString(received_message.content), "Message Sent == Message Decrypted");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.