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.">
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." />
<li><ahref="#negotiation-of-a-11-chat-amongst-multiple-participants-group-chat">Negotiation of a 1:1 chat amongst multiple participants (group chat)</a>
<p>For more information on account generation and trust establishment, see <ahref="https://specs.status.im/spec/2">2/ACCOUNT</a></p>
<h3id="post-negotiation">
Post Negotiation
<aclass="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>
<h3id="session-management">
Session management
<aclass="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><ahref="/spec/53/">53/WAKU2-X3DH</a>, the session management is described in <ahref="/spec/54/">54/WAKU2-X3DH-SESSIONS</a></p>
</li>
<li>
<p><ahref="/spec/35/">35/WAKU2-NOISE</a>, the session management is described in <ahref="/spec/37/">37/WAKU2-NOISE-SESSIONS</a></p>
</span></span></span><spanstyle="display:flex;"><span><spanstyle="color:#960050;background-color:#1e0010"></span><spanstyle="color:#75715e">// The chat id of the private group chat
</span></span></span><spanstyle="display:flex;"><span><spanstyle="color:#75715e"></span><spanstyle="color:#75715e">// derived in the following way:
</span></span></span><spanstyle="display:flex;"><span><spanstyle="color:#75715e"></span><spanstyle="color:#75715e">// This chat_id MUST be validated by all participants
</span></span></span><spanstyle="display:flex;"><span><spanstyle="color:#960050;background-color:#1e0010"></span><spanstyle="color:#75715e">// A list of events for this group chat, first 65 bytes are the signature, then is a
</span></span></span><spanstyle="display:flex;"><span><spanstyle="color:#960050;background-color:#1e0010"></span><spanstyle="color:#75715e">// An optional chat message
</span></span></span><spanstyle="display:flex;"><span><spanstyle="color:#960050;background-color:#1e0010"></span><spanstyle="color:#75715e">// An optional reaction to a message
</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>’s.</p>
<p>where <code>MembershipUpdateEvent</code> is defined as follows:</p>
</span></span></span><spanstyle="display:flex;"><span><spanstyle="color:#960050;background-color:#1e0010"></span><spanstyle="color:#75715e">// Lamport timestamp of the event
</span></span></span><spanstyle="display:flex;"><span><spanstyle="color:#960050;background-color:#1e0010"></span><spanstyle="color:#75715e">// Optional list of public keys of the targets of the action
</span></span></span><spanstyle="display:flex;"><span><spanstyle="color:#75715e"></span><spanstyle="color:#66d9ef">repeated</span><spanstyle="color:#66d9ef">string</span> members <spanstyle="color:#f92672">=</span><spanstyle="color:#ae81ff">2</span>;<spanstyle="color:#960050;background-color:#1e0010">
</span></span></span><spanstyle="display:flex;"><span><spanstyle="color:#960050;background-color:#1e0010"></span><spanstyle="color:#75715e">// Name of the chat for the CHAT_CREATED/NAME_CHANGED event types
</span></span></span><spanstyle="display:flex;"><span><spanstyle="color:#75715e"></span><spanstyle="color:#66d9ef">string</span> name <spanstyle="color:#f92672">=</span><spanstyle="color:#ae81ff">3</span>;<spanstyle="color:#960050;background-color:#1e0010">
</span></span></span><spanstyle="display:flex;"><span><spanstyle="color:#960050;background-color:#1e0010"></span><spanstyle="color:#75715e">// The type of the event
</span></span></span><spanstyle="display:flex;"><span><spanstyle="color:#75715e"></span> EventType type <spanstyle="color:#f92672">=</span><spanstyle="color:#ae81ff">4</span>;<spanstyle="color:#960050;background-color:#1e0010">
</span></span></span><spanstyle="display:flex;"><span><spanstyle="color:#960050;background-color:#1e0010"></span><spanstyle="color:#75715e">// Color of the chat for the CHAT_CREATED/COLOR_CHANGED event types
</span></span></span><spanstyle="display:flex;"><span><spanstyle="color:#75715e"></span><spanstyle="color:#66d9ef">string</span> color <spanstyle="color:#f92672">=</span><spanstyle="color:#ae81ff">5</span>;<spanstyle="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 <ahref="https://github.com/status-im/status-go/blob/5fd9e93e9c298ed087e6716d857a3951dbfb3c1e/protocol/protobuf/chat_message.proto#L1">chat_message.proto</a> and <ahref="https://github.com/status-im/status-go/blob/5fd9e93e9c298ed087e6716d857a3951dbfb3c1e/protocol/protobuf/emoji_reaction.proto">emoji_reaction.proto</a>.</p>
<h5id="chat-created">
Chat Created
<aclass="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>
<h5id="name-changed">
Name Changed
<aclass="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>
<h5id="members-added">
Members Added
<aclass="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>
<h5id="member-joined">
Member Joined
<aclass="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>
<h5id="member-removed">
Member Removed
<aclass="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>
<h5id="admins-added">
Admins Added
<aclass="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>
<h5id="admin-removed">
Admin Removed
<aclass="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>
<h5id="color-changed">
Color Changed
<aclass="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>
<h5id="image-changed">
Image Changed
<aclass="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>
<li>Inherits the security considerations of the key-exchange mechanism used, e.g., <ahref="/spec/53/">53/WAKU2-X3DH</a> or <ahref="/spec/35/">35/WAKU2-NOISE</a></li>
</ol>
<h1id="copyright">
Copyright
<aclass="anchor"href="#copyright">#</a>
</h1>
<p>Copyright and related rights waived via <ahref="https://creativecommons.org/publicdomain/zero/1.0/">CC0</a>.</p>
<li><ahref="#negotiation-of-a-11-chat-amongst-multiple-participants-group-chat">Negotiation of a 1:1 chat amongst multiple participants (group chat)</a>