rfc/spec/55/index.html

573 lines
30 KiB
HTML

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta name="generator" content="Hugo 0.106.0">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Abstract # This specification describes how the Status 1-to-1 chat protocol is implemented on top of the Waku v2 protocol. This protocol can be used to send messages to a single recipient.
Terminology # Participant: A participant is a user that is able to send and receive messages. 1-to-1 chat: A chat between two participants. Public chat: A chat where any participant can join and read messages. Private chat: A chat where only invited participants can join and read messages.">
<meta name="theme-color" content="#FFFFFF"><meta property="og:title" content="55/STATUS-1TO1-CHAT" />
<meta property="og:description" content="Abstract # This specification describes how the Status 1-to-1 chat protocol is implemented on top of the Waku v2 protocol. This protocol can be used to send messages to a single recipient.
Terminology # Participant: A participant is a user that is able to send and receive messages. 1-to-1 chat: A chat between two participants. Public chat: A chat where any participant can join and read messages. Private chat: A chat where only invited participants can join and read messages." />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://rfc.vac.dev/spec/55/" /><meta property="article:section" content="docs" />
<title>55/STATUS-1TO1-CHAT | Vac RFC</title>
<link rel="manifest" href="/manifest.json">
<link rel="icon" href="/favicon.png" type="image/x-icon">
<link rel="stylesheet" href="/book.min.e935e20bd0d469378cb482f0958edf258c731a4f895dccd55799c6fbc8043f23.css" integrity="sha256-6TXiC9DUaTeMtILwlY7fJYxzGk&#43;JXczVV5nG&#43;8gEPyM=">
<script defer src="/en.search.min.326d043fa8e332a51e3f9983730a7fd874d98704640c54917d58b785c9d774b9.js" integrity="sha256-Mm0EP6jjMqUeP5mDcwp/2HTZhwRkDFSRfVi3hcnXdLk="></script>
<!--
Made with Book Theme
https://github.com/alex-shpak/hugo-book
-->
</head>
<body dir="ltr">
<input type="checkbox" class="hidden toggle" id="menu-control" />
<input type="checkbox" class="hidden toggle" id="toc-control" />
<main class="container flex">
<aside class="book-menu">
<div class="book-menu-content">
<nav>
<h2 class="book-brand">
<a href="/"><span>Vac RFC</span>
</a>
</h2>
<div class="book-search">
<input type="text" id="book-search-input" placeholder="Search" aria-label="Search" maxlength="64" data-hotkeys="s/" />
<div class="book-search-spinner hidden"></div>
<ul id="book-search-results"></ul>
</div>
<ul>
<li>Raw
<ul>
<li><a href="/spec/20/">20/TOY-ETH-PM</a></li>
<li><a href="/spec/24/">24/STATUS-CURATION</a></li>
<li><a href="/spec/28/">28/STATUS-FEATURING</a></li>
<li><a href="/spec/31/">31/WAKU2-ENR</a></li>
<li><a href="/spec/32/">32/RLN-V1</a></li>
<li><a href="/spec/34/">34/WAKU2-PEER-EXCHANGE</a></li>
<li><a href="/spec/35/">35/WAKU2-NOISE</a></li>
<li><a href="/spec/37/">37/WAKU2-NOISE-SESSIONS</a></li>
<li><a href="/spec/38/">38/CONSENSUS-CLARO</a></li>
<li><a href="/spec/43/">43/WAKU2-NOISE-PAIRING</a></li>
<li><a href="/spec/44/">44/WAKU2-DANDELION</a></li>
<li><a href="/spec/45/">45/WAKU2-ADVERSARIAL-MODELS</a></li>
<li><a href="/spec/46/">46/GOSSIPSUB-TOR-PUSH</a></li>
<li><a href="/spec/47/">47/WAKU2-TOR-PUSH</a></li>
<li><a href="/spec/48/">48/RLN-INTEREP-SPEC</a></li>
<li><a href="/spec/51/">51/WAKU2-RELAY-SHARDING</a></li>
<li><a href="/spec/52/">52/WAKU2-RELAY-STATIC-SHARD-ALLOC</a></li>
<li><a href="/spec/57/">57/STATUS-Simple-Scaling</a></li>
<li><a href="/spec/58/">58/RLN-V2</a></li>
</ul>
</li>
<li>Draft
<ul>
<li><a href="/spec/1/">1/COSS</a></li>
<li><a href="/spec/3/">3/REMOTE-LOG</a></li>
<li><a href="/spec/4/">4/MVDS-META</a></li>
<li><a href="/spec/10/">10/WAKU2</a></li>
<li><a href="/spec/12/">12/WAKU2-FILTER</a></li>
<li><a href="/spec/13/">13/WAKU2-STORE</a></li>
<li><a href="/spec/14/">14/WAKU2-MESSAGE</a></li>
<li><a href="/spec/15/">15/WAKU2-BRIDGE</a></li>
<li><a href="/spec/16/">16/WAKU2-RPC</a></li>
<li><a href="/spec/17/">17/WAKU2-RLN-RELAY</a></li>
<li><a href="/spec/18/">18/WAKU2-SWAP</a></li>
<li><a href="/spec/19/">19/WAKU2-LIGHTPUSH</a></li>
<li><a href="/spec/21/">21/WAKU2-FTSTORE</a></li>
<li><a href="/spec/22/">22/TOY-CHAT</a></li>
<li><a href="/spec/23/">23/WAKU2-TOPICS</a></li>
<li><a href="/spec/26/">26/WAKU2-PAYLOAD</a></li>
<li><a href="/spec/27/">27/WAKU2-PEERS</a></li>
<li><a href="/spec/29/">29/WAKU2-CONFIG</a></li>
<li><a href="/spec/30/">30/ADAPTIVE-NODES</a></li>
<li><a href="/spec/33/">33/WAKU2-DISCV5</a></li>
<li><a href="/spec/36/">36/WAKU2-BINDINGS-API</a></li>
<li><a href="/spec/53/">53/WAKU2-X3DH</a></li>
<li><a href="/spec/54/">54/WAKU2-X3DH-SESSIONS</a></li>
<li><a href="/spec/55/"class=active>55/STATUS-1TO1-CHAT</a></li>
<li><a href="/spec/56/">56/STATUS-COMMUNITIES</a></li>
</ul>
</li>
<li>Stable
<ul>
<li><a href="/spec/2/">2/MVDS</a></li>
<li><a href="/spec/6/">6/WAKU1</a></li>
<li><a href="/spec/7/">7/WAKU-DATA</a></li>
<li><a href="/spec/8/">8/WAKU-MAIL</a></li>
<li><a href="/spec/9/">9/WAKU-RPC</a></li>
<li><a href="/spec/11/">11/WAKU2-RELAY</a></li>
</ul>
</li>
<li>Deprecated
<ul>
<li><a href="/spec/5/">5/WAKU0</a></li>
</ul>
</li>
<li>Retired</li>
</ul>
</nav>
<script>(function(){var e=document.querySelector("aside.book-menu nav");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script>
</div>
</aside>
<div class="book-page">
<header class="book-header">
<div class="flex align-center justify-between">
<label for="menu-control">
<img src="/svg/menu.svg" class="book-icon" alt="Menu" />
</label>
<strong>55/STATUS-1TO1-CHAT</strong>
<label for="toc-control">
<img src="/svg/toc.svg" class="book-icon" alt="Table of Contents" />
</label>
</div>
<aside class="hidden clearfix">
<nav id="TableOfContents">
<ul>
<li><a href="#abstract">Abstract</a></li>
<li><a href="#terminology">Terminology</a></li>
<li><a href="#background">Background</a></li>
<li><a href="#specification">Specification</a>
<ul>
<li><a href="#overview">Overview</a></li>
<li><a href="#flow">Flow</a>
<ul>
<li><a href="#negotiation-of-a-11-chat">Negotiation of a 1:1 chat</a></li>
<li><a href="#post-negotiation">Post Negotiation</a></li>
<li><a href="#session-management">Session management</a></li>
</ul>
</li>
<li><a href="#negotiation-of-a-11-chat-amongst-multiple-participants-group-chat">Negotiation of a 1:1 chat amongst multiple participants (group chat)</a>
<ul>
<li><a href="#flow-1">Flow</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#security-considerations">Security Considerations</a></li>
<li><a href="#copyright">Copyright</a></li>
<li><a href="#references">References</a></li>
</ul>
</nav>
</aside>
</header>
<article class="markdown">
<h1 id="55status-1to1-chat">
55/STATUS-1TO1-CHAT
<a class="anchor" href="#55status-1to1-chat">#</a>
</h1>
<h1 id="status-1-to-1-chat">
Status 1-to-1 Chat
<a class="anchor" href="#status-1-to-1-chat">#</a>
</h1>
<img src="https://img.shields.io/badge/status-draft-blue?style=flat-square" />
<ul>
<li>Status: draft</li>
<li>Editor: Aaryamann Challani <a href="mailto:aaryamann@status.im">aaryamann@status.im</a></li>
<li>Contributors:
Andrea Piana <a href="mailto:andreap@status.im">andreap@status.im</a>
,
Pedro Pombeiro <a href="mailto:pedro@status.im">pedro@status.im</a>
,
Corey Petty <a href="mailto:corey@status.im">corey@status.im</a>
,
Oskar Thorén <a href="mailto:oskar@status.im">oskar@status.im</a>
,
Dean Eigenmann <a href="mailto:dean@status.im">dean@status.im</a>
</li>
</ul><h1 id="abstract">
Abstract
<a class="anchor" href="#abstract">#</a>
</h1>
<p>This specification describes how the Status 1-to-1 chat protocol is implemented on top of the Waku v2 protocol.
This protocol can be used to send messages to a single recipient.</p>
<h1 id="terminology">
Terminology
<a class="anchor" href="#terminology">#</a>
</h1>
<ul>
<li><strong>Participant</strong>: A participant is a user that is able to send and receive messages.</li>
<li><strong>1-to-1 chat</strong>: A chat between two participants.</li>
<li><strong>Public chat</strong>: A chat where any participant can join and read messages.</li>
<li><strong>Private chat</strong>: A chat where only invited participants can join and read messages.</li>
<li><strong>Group chat</strong>: A chat where multiple select participants can join and read messages.</li>
<li><strong>Group admin</strong>: A participant that is able to add/remove participants from a group chat.</li>
</ul>
<h1 id="background">
Background
<a class="anchor" href="#background">#</a>
</h1>
<p>This document describes how 2 peers communicate with each other to send messages in a 1-to-1 chat, with privacy and authenticity guarantees.</p>
<h1 id="specification">
Specification
<a class="anchor" href="#specification">#</a>
</h1>
<h2 id="overview">
Overview
<a class="anchor" href="#overview">#</a>
</h2>
<p>This protocol MAY use any key-exchange mechanism previously discussed -</p>
<ol>
<li><a href="/spec/53/">53/WAKU2-X3DH</a></li>
<li><a href="/spec/35/">35/WAKU2-NOISE</a></li>
</ol>
<p>This protocol can provide end-to-end encryption to give peers a strong degree of privacy and security.
Public chat messages are publicly readable by anyone since there&rsquo;s no permission model for who is participating in a public chat.</p>
<h2 id="flow">
Flow
<a class="anchor" href="#flow">#</a>
</h2>
<h3 id="negotiation-of-a-11-chat">
Negotiation of a 1:1 chat
<a class="anchor" href="#negotiation-of-a-11-chat">#</a>
</h3>
<p>There are two phases in the initial negotiation of a 1:1 chat:</p>
<ol>
<li><strong>Identity verification</strong> (e.g., face-to-face contact exchange through QR code, Identicon matching).
A QR code serves two purposes simultaneously - identity verification and initial key material retrieval;</li>
<li><strong>Asynchronous initial key exchange</strong></li>
</ol>
<p>For more information on account generation and trust establishment, see <a href="https://specs.status.im/spec/2">2/ACCOUNT</a></p>
<h3 id="post-negotiation">
Post Negotiation
<a class="anchor" href="#post-negotiation">#</a>
</h3>
<p>After the peers have shared their public key material, a 1:1 chat can be established using the methods described in the key-exchange protocols mentioned above.</p>
<h3 id="session-management">
Session management
<a class="anchor" href="#session-management">#</a>
</h3>
<p>The 1:1 chat is made robust by having sessions between peers.
It is handled by the key-exchange protocol used. For example,</p>
<ol>
<li>
<p><a href="/spec/53/">53/WAKU2-X3DH</a>, the session management is described in <a href="/spec/54/">54/WAKU2-X3DH-SESSIONS</a></p>
</li>
<li>
<p><a href="/spec/35/">35/WAKU2-NOISE</a>, the session management is described in <a href="/spec/37/">37/WAKU2-NOISE-SESSIONS</a></p>
</li>
</ol>
<h2 id="negotiation-of-a-11-chat-amongst-multiple-participants-group-chat">
Negotiation of a 1:1 chat amongst multiple participants (group chat)
<a class="anchor" href="#negotiation-of-a-11-chat-amongst-multiple-participants-group-chat">#</a>
</h2>
<p>A small, private group chat can be constructed by having multiple participants negotiate a 1:1 chat amongst each other.
Each participant MUST maintain a session with all other participants in the group chat.
This allows for a group chat to be created with a small number of participants.</p>
<p>However, this method does not scale as the number of participants increases, for the following reasons -</p>
<ol>
<li>The number of messages sent over the network increases with the number of participants.</li>
<li>Handling the X3DH key exchange for each participant is computationally expensive.</li>
</ol>
<p>The above issues are addressed in <a href="/spec/56/">56/STATUS-COMMUNITIES</a>, with other trade-offs.</p>
<h3 id="flow-1">
Flow
<a class="anchor" href="#flow-1">#</a>
</h3>
<p>The following flow describes how a group chat is created and maintained.</p>
<h4 id="membership-update-flow">
Membership Update Flow
<a class="anchor" href="#membership-update-flow">#</a>
</h4>
<p>Membership updates have the following wire format:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-protobuf" data-lang="protobuf"><span style="display:flex;"><span><span style="color:#66d9ef">message</span> <span style="color:#a6e22e">MembershipUpdateMessage</span> {<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> <span style="color:#75715e">// The chat id of the private group chat
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> <span style="color:#75715e">// derived in the following way:
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> <span style="color:#75715e">// chat_id = hex(chat_creator_public_key) + &#34;-&#34; + random_uuid
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> <span style="color:#75715e">// This chat_id MUST be validated by all participants
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> <span style="color:#66d9ef">string</span> chat_id <span style="color:#f92672">=</span> <span style="color:#ae81ff">1</span>;<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> <span style="color:#75715e">// A list of events for this group chat, first 65 bytes are the signature, then is a
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> <span style="color:#75715e">// protobuf encoded MembershipUpdateEvent
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> <span style="color:#66d9ef">repeated</span> <span style="color:#66d9ef">bytes</span> events <span style="color:#f92672">=</span> <span style="color:#ae81ff">2</span>;<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> <span style="color:#66d9ef">oneof</span> chat_entity {<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> <span style="color:#75715e">// An optional chat message
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> ChatMessage <span style="color:#66d9ef">message</span> <span style="color:#f92672">=</span> <span style="color:#ae81ff">3</span>;<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> <span style="color:#75715e">// An optional reaction to a message
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> EmojiReaction emoji_reaction <span style="color:#f92672">=</span> <span style="color:#ae81ff">4</span>; <span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> }<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span>}<span style="color:#960050;background-color:#1e0010">
</span></span></span></code></pre></div><p>Note that in <code>events</code>, the first element is the signature, and all other elements after are encoded <code>MembershipUpdateEvent</code>&rsquo;s.</p>
<p>where <code>MembershipUpdateEvent</code> is defined as follows:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-protobuf" data-lang="protobuf"><span style="display:flex;"><span><span style="color:#66d9ef">message</span> <span style="color:#a6e22e">MembershipUpdateEvent</span> {<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> <span style="color:#75715e">// Lamport timestamp of the event
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> <span style="color:#66d9ef">uint64</span> clock <span style="color:#f92672">=</span> <span style="color:#ae81ff">1</span>;<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> <span style="color:#75715e">// Optional list of public keys of the targets of the action
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> <span style="color:#66d9ef">repeated</span> <span style="color:#66d9ef">string</span> members <span style="color:#f92672">=</span> <span style="color:#ae81ff">2</span>;<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> <span style="color:#75715e">// Name of the chat for the CHAT_CREATED/NAME_CHANGED event types
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> <span style="color:#66d9ef">string</span> name <span style="color:#f92672">=</span> <span style="color:#ae81ff">3</span>;<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> <span style="color:#75715e">// The type of the event
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> EventType type <span style="color:#f92672">=</span> <span style="color:#ae81ff">4</span>;<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> <span style="color:#75715e">// Color of the chat for the CHAT_CREATED/COLOR_CHANGED event types
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> <span style="color:#66d9ef">string</span> color <span style="color:#f92672">=</span> <span style="color:#ae81ff">5</span>;<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> <span style="color:#75715e">// Chat image
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> <span style="color:#66d9ef">bytes</span> image <span style="color:#f92672">=</span> <span style="color:#ae81ff">6</span>;<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> <span style="color:#66d9ef">enum</span> EventType {<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> UNKNOWN <span style="color:#f92672">=</span> <span style="color:#ae81ff">0</span>;<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span> CHAT_CREATED <span style="color:#f92672">=</span> <span style="color:#ae81ff">1</span>; <span style="color:#75715e">// See [CHAT_CREATED](#chat-created)
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> NAME_CHANGED <span style="color:#f92672">=</span> <span style="color:#ae81ff">2</span>; <span style="color:#75715e">// See [NAME_CHANGED](#name-changed)
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> MEMBERS_ADDED <span style="color:#f92672">=</span> <span style="color:#ae81ff">3</span>; <span style="color:#75715e">// See [MEMBERS_ADDED](#members-added)
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> MEMBER_JOINED <span style="color:#f92672">=</span> <span style="color:#ae81ff">4</span>; <span style="color:#75715e">// See [MEMBER_JOINED](#member-joined)
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> MEMBER_REMOVED <span style="color:#f92672">=</span> <span style="color:#ae81ff">5</span>; <span style="color:#75715e">// See [MEMBER_REMOVED](#member-removed)
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> ADMINS_ADDED <span style="color:#f92672">=</span> <span style="color:#ae81ff">6</span>; <span style="color:#75715e">// See [ADMINS_ADDED](#admins-added)
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> ADMIN_REMOVED <span style="color:#f92672">=</span> <span style="color:#ae81ff">7</span>; <span style="color:#75715e">// See [ADMIN_REMOVED](#admin-removed)
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> COLOR_CHANGED <span style="color:#f92672">=</span> <span style="color:#ae81ff">8</span>; <span style="color:#75715e">// See [COLOR_CHANGED](#color-changed)
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> IMAGE_CHANGED <span style="color:#f92672">=</span> <span style="color:#ae81ff">9</span>; <span style="color:#75715e">// See [IMAGE_CHANGED](#image-changed)
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> }<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span>}<span style="color:#960050;background-color:#1e0010">
</span></span></span></code></pre></div><!-- raw HTML omitted -->
<p>Note that the definitions for <code>ChatMessage</code> and <code>EmojiReaction</code> can be found in <a href="https://github.com/status-im/status-go/blob/5fd9e93e9c298ed087e6716d857a3951dbfb3c1e/protocol/protobuf/chat_message.proto#L1">chat_message.proto</a> and <a href="https://github.com/status-im/status-go/blob/5fd9e93e9c298ed087e6716d857a3951dbfb3c1e/protocol/protobuf/emoji_reaction.proto">emoji_reaction.proto</a>.</p>
<h5 id="chat-created">
Chat Created
<a class="anchor" href="#chat-created">#</a>
</h5>
<p>When creating a group chat, this is the first event that MUST be sent.
Any event with a clock value lower than this MUST be discarded.
Upon receiving this event a client MUST validate the <code>chat_id</code> provided with the update and create a chat with identified by <code>chat_id</code>.</p>
<p>By default, the creator of the group chat is the only group admin.</p>
<h5 id="name-changed">
Name Changed
<a class="anchor" href="#name-changed">#</a>
</h5>
<p>To change the name of the group chat, group admins MUST use a <code>NAME_CHANGED</code> event.
Upon receiving this event a client MUST validate the <code>chat_id</code> provided with the updates and MUST ensure the author of the event is an admin of the chat, otherwise the event MUST be ignored.
If the event is valid the chat name SHOULD be changed according to the provided message.</p>
<h5 id="members-added">
Members Added
<a class="anchor" href="#members-added">#</a>
</h5>
<p>To add members to the chat, group admins MUST use a <code>MEMBERS_ADDED</code> event.
Upon receiving this event a participant MUST validate the <code>chat_id</code> provided with the updates and MUST ensure the author of the event is an admin of the chat, otherwise the event MUST be ignored.
If the event is valid, a participant MUST update the list of members of the chat who have not joined, adding the members received.</p>
<h5 id="member-joined">
Member Joined
<a class="anchor" href="#member-joined">#</a>
</h5>
<p>To signal the intent to start receiving messages from a given chat, new participants MUST use a <code>MEMBER_JOINED</code> event.
Upon receiving this event a participant MUST validate the <code>chat_id</code> provided with the updates.
If the event is valid a participant MUST add the new participant to the list of participants stored locally.
Any message sent to the group chat MUST now include the new participant.</p>
<h5 id="member-removed">
Member Removed
<a class="anchor" href="#member-removed">#</a>
</h5>
<p>There are two ways in which a member MAY be removed from a group chat:</p>
<ul>
<li>A member MAY leave the chat by sending a <code>MEMBER_REMOVED</code> event, with the <code>members</code> field containing their own public key.</li>
<li>An admin MAY remove a member by sending a <code>MEMBER_REMOVED</code> event, with the <code>members</code> field containing the public key of the member to be removed.</li>
</ul>
<p>Each participant MUST validate the <code>chat_id</code> provided with the updates and MUST ensure the author of the event is an admin of the chat, otherwise the event MUST be ignored.
If the event is valid, a participant MUST update the local list of members accordingly.</p>
<h5 id="admins-added">
Admins Added
<a class="anchor" href="#admins-added">#</a>
</h5>
<p>To promote participants to group admin, group admins MUST use an <code>ADMINS_ADDED</code> event.
Upon receiving this event, a participant MUST validate the <code>chat_id</code> provided with the updates, MUST ensure the author of the event is an admin of the chat, otherwise the event MUST be ignored.
If the event is valid, a participant MUST update the list of admins of the chat accordingly.</p>
<h5 id="admin-removed">
Admin Removed
<a class="anchor" href="#admin-removed">#</a>
</h5>
<p>Group admins MUST NOT be able to remove other group admins.
An admin MAY remove themselves by sending an <code>ADMIN_REMOVED</code> event, with the <code>members</code> field containing their own public key.
Each participant MUST validate the <code>chat_id</code> provided with the updates and MUST ensure the author of the event is an admin of the chat, otherwise the event MUST be ignored.
If the event is valid, a participant MUST update the list of admins of the chat accordingly.</p>
<h5 id="color-changed">
Color Changed
<a class="anchor" href="#color-changed">#</a>
</h5>
<p>To change the text color of the group chat name, group admins MUST use a <code>COLOR_CHANGED</code> event.</p>
<h5 id="image-changed">
Image Changed
<a class="anchor" href="#image-changed">#</a>
</h5>
<p>To change the display image of the group chat, group admins MUST use an <code>IMAGE_CHANGED</code> event.</p>
<h1 id="security-considerations">
Security Considerations
<a class="anchor" href="#security-considerations">#</a>
</h1>
<ol>
<li>Inherits the security considerations of the key-exchange mechanism used, e.g., <a href="/spec/53/">53/WAKU2-X3DH</a> or <a href="/spec/35/">35/WAKU2-NOISE</a></li>
</ol>
<h1 id="copyright">
Copyright
<a class="anchor" href="#copyright">#</a>
</h1>
<p>Copyright and related rights waived via <a href="https://creativecommons.org/publicdomain/zero/1.0/">CC0</a>.</p>
<h1 id="references">
References
<a class="anchor" href="#references">#</a>
</h1>
<ol>
<li><a href="https://specs.status.im/spec/2">2/ACCOUNT</a></li>
<li><a href="/spec/53/">53/WAKU2-X3DH</a></li>
<li><a href="/spec/35/">35/WAKU2-NOISE</a></li>
<li><a href="/spec/10/">10/WAKU2</a></li>
<li><a href="https://specs.status.im/draft/7">7/GROUP-CHAT</a></li>
</ol>
</article>
<footer class="book-footer">
<div class="flex flex-wrap justify-between">
</div>
</footer>
<div class="book-comments">
</div>
<label for="menu-control" class="hidden book-menu-overlay"></label>
</div>
<aside class="book-toc">
<div class="book-toc-content">
<nav id="TableOfContents">
<ul>
<li><a href="#abstract">Abstract</a></li>
<li><a href="#terminology">Terminology</a></li>
<li><a href="#background">Background</a></li>
<li><a href="#specification">Specification</a>
<ul>
<li><a href="#overview">Overview</a></li>
<li><a href="#flow">Flow</a>
<ul>
<li><a href="#negotiation-of-a-11-chat">Negotiation of a 1:1 chat</a></li>
<li><a href="#post-negotiation">Post Negotiation</a></li>
<li><a href="#session-management">Session management</a></li>
</ul>
</li>
<li><a href="#negotiation-of-a-11-chat-amongst-multiple-participants-group-chat">Negotiation of a 1:1 chat amongst multiple participants (group chat)</a>
<ul>
<li><a href="#flow-1">Flow</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#security-considerations">Security Considerations</a></li>
<li><a href="#copyright">Copyright</a></li>
<li><a href="#references">References</a></li>
</ul>
</nav>
</div>
</aside>
</main>
</body>
</html>