Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
3890e57
Add Session Pro master key derivation
Doy-lee Jul 31, 2025
5582329
Only give 64b skey from session pro keygen
Doy-lee Aug 1, 2025
f241f86
Apply _hex_u changes to rest of ed25519 tests
Doy-lee Aug 1, 2025
d9b3b09
Use cleared_u32 and 64 from sodium_array header
Doy-lee Aug 1, 2025
d7ba32e
Linting fix
Doy-lee Aug 1, 2025
dd59713
Add basic pro proof verification functions
Doy-lee Jul 31, 2025
d4d6176
Reformat the string split in test_config_userprofile
Doy-lee Aug 4, 2025
af301db
Add pro proof and rotating key pair to user profile
Doy-lee Aug 4, 2025
176d72a
Add c wrappers for Session Pro and proofs
Doy-lee Aug 5, 2025
69f38a7
Update protobufs for Pro and pro proofs
Doy-lee Aug 5, 2025
c397b15
Typedef array u8x32, add it to types.hpp anad use it in new code
Doy-lee Aug 5, 2025
f7047b2
Add Pro message to Content and decrypt it
Doy-lee Aug 6, 2025
f23f718
Update Session protobuf files to session-ios at 084e58f
Doy-lee Aug 8, 2025
6abed5a
Revise the PRO protobuf structures
Doy-lee Aug 8, 2025
fc95375
Port encrypt for namespace into libsession
Doy-lee Aug 8, 2025
af52798
Update decrypt function to return the envelope and the metadata
Doy-lee Aug 8, 2025
ffe0b5b
Add documentation for new session protocol functions
Doy-lee Aug 8, 2025
654b6b6
Add c bindings for new encryption functions
Doy-lee Aug 11, 2025
afb7ad2
Revise docs for session protocol c header
Doy-lee Aug 11, 2025
a1d90a5
Fix incorrect detection of higher char limits and non-optional pro sigs
Doy-lee Aug 12, 2025
c384713
Note that closed groups handles both legacy/non-legacy keys
Doy-lee Aug 12, 2025
9841a4e
Avoid required files in pro messages, handle non-encrypted contents i…
Doy-lee Aug 13, 2025
539f77e
Regen the protobufs w/ non required fields for pro structures
Doy-lee Aug 13, 2025
d58e65a
Allow envelope decrypt to handle encrypted v2 group envelopes
Doy-lee Aug 14, 2025
0bacb89
Do not enforce library types in C interface
Doy-lee Aug 14, 2025
39b8edc
Pro version field should use a key that sorts to the top
Doy-lee Aug 14, 2025
4e2b3d0
Fix C session protocol using std::span and missing comments
Doy-lee Aug 14, 2025
899f2e0
Fixup some comments, add missing x25519 pubkey from C decrypted envelope
Doy-lee Aug 14, 2025
817a102
Linting
Doy-lee Aug 14, 2025
4bc5480
Fix pro tests breaking due to version change to @
Doy-lee Aug 14, 2025
8b5e1fd
Move group msg encryption primitive into session encrypt, avoids circ…
Doy-lee Aug 15, 2025
9bb7d27
Move group encryption into session encrypt
Doy-lee Aug 18, 2025
e36c6e5
Update nomenclamenture, Closed/OpenGroup to Group/Community respectively
Doy-lee Aug 18, 2025
cb207d7
Add some missing typedefs on C structs
Doy-lee Aug 18, 2025
7356825
Document the free-eing requirement on the C interface for session pro…
Doy-lee Aug 18, 2025
68c27ff
We cannot enforce the presence of a pro signature
Doy-lee Aug 18, 2025
ecfc9b7
Don't use assert in test key-gen which breaks in release mode
Doy-lee Aug 19, 2025
a5c4ed8
Add error logging to C apis
Doy-lee Aug 19, 2025
7afeb59
Add TODO on the purpose of PUBKEY in pro_backend
Doy-lee Aug 20, 2025
633b199
Add note that character limit is UTF16 code units for now
Doy-lee Aug 20, 2025
608b6a5
Remove outdated comment, these encrypt dests just receive plaintext
Doy-lee Aug 20, 2025
f7e5a54
Remove the CPP session protocol tests, keep C API
Doy-lee Aug 20, 2025
a068576
Fix groups message not encrypting correctly
Doy-lee Aug 20, 2025
8bfeb88
Remove envelope type, it is inferred from the namespace
Doy-lee Aug 20, 2025
d3ff9a4
Encapsulate the freeing of session protocol encrypt/decrypt funcs
Doy-lee Aug 20, 2025
0b2dbe2
Prohibit the creation of legacy groups messages, no longer supported
Doy-lee Aug 20, 2025
ea411a8
Fix linting
Doy-lee Aug 20, 2025
d5c6e26
Remove the need for ProStatus::Nil by using std::optional
Doy-lee Aug 21, 2025
91d8be7
Add docs to pro config
Doy-lee Aug 21, 2025
6c6d455
Add helper functions for getting PRO_STATUS from proof standalone fro…
Doy-lee Aug 21, 2025
37eb19a
Re-add missing wrapping of 1o1 messages
Doy-lee Aug 25, 2025
2a49789
Mitigate snprintf error prone return value
Doy-lee Aug 25, 2025
680d077
Address some outdated doc comments
Doy-lee Aug 25, 2025
bf5e703
Use bytes32/64/33 in session protocol, add wrapper encrypt for {1o1,g…
Doy-lee Aug 29, 2025
fd5a5dd
Remove destinations that don't encrypt
Doy-lee Aug 29, 2025
8d0948c
Remove namespace from encrypt for destination
Doy-lee Aug 29, 2025
f9ae0d3
Linting
Doy-lee Aug 29, 2025
a0fbd43
Add missing memory header for zstd
Doy-lee Sep 24, 2025
db2e063
Move ProProof into session_protocol.hpp
Doy-lee Sep 24, 2025
c564710
Add pro proof and rotating key pair to user profile
Doy-lee Aug 4, 2025
b2f9d0a
Add Pro message to Content and decrypt it
Doy-lee Aug 6, 2025
c0f76dd
Port encrypt for namespace into libsession
Doy-lee Aug 8, 2025
4332109
Linting
Doy-lee Aug 14, 2025
9ac202e
Move group msg encryption primitive into session encrypt, avoids circ…
Doy-lee Aug 15, 2025
8da20ce
Add docs to pro config
Doy-lee Aug 21, 2025
ee39233
Polish C++ pro backend APIs and add C variants
Doy-lee Aug 22, 2025
97c1009
Document the new c helper functions
Doy-lee Aug 25, 2025
50913c5
Document the dev flow for pro backend
Doy-lee Aug 25, 2025
ac3fb1c
Test pro backend against local dev server
Doy-lee Aug 27, 2025
9090e2d
Add revocation tests, guard CURL tests behind CMake option
Doy-lee Aug 27, 2025
92a5516
Update readme with new instructions for pro backend dev mode tests
Doy-lee Aug 27, 2025
56f86ed
Add more notes on role/usage of protocol.hpp
Doy-lee Aug 27, 2025
6d2befe
Add payment provider to the pro payments items
Doy-lee Aug 27, 2025
58a746c
Add Session Pro payment provider metadata, e.g. links to support pages
Doy-lee Aug 27, 2025
d872ab1
Fix formatting
Doy-lee Aug 27, 2025
2c907bc
Make parsing a static function
Doy-lee Aug 28, 2025
ed3dcba
Remove duplicated recipient pubkey field
Doy-lee Aug 29, 2025
d4d7c32
Add UTF8/UTF16 codepoint count via new simdutf submodule
Doy-lee Aug 29, 2025
545e385
Add type annotations in the C interface
Doy-lee Aug 29, 2025
2a92e6d
Update pro_features_for_utf* naming scheme, add read-only note on err…
Doy-lee Sep 3, 2025
8674fe1
Update pro backend layer with changes to API
Doy-lee Sep 17, 2025
49a4275
Update pro payments to pro status endpoint
Doy-lee Sep 18, 2025
e3c1285
Update pro backend to use millisecond timestamps
Doy-lee Sep 19, 2025
986feb6
Update pro backend status API to handle new grace ts response
Doy-lee Sep 23, 2025
10f40ec
Fix broken tests due to mismatched timestamp magnitude
Doy-lee Sep 23, 2025
20659e2
Fix broken tests after rebase
Doy-lee Sep 25, 2025
3436d89
Formatting
Doy-lee Sep 25, 2025
890266d
Use non-SSH url for simdutf
Doy-lee Sep 25, 2025
041cc02
Remove null-checks for args marked NON-NULL
Doy-lee Sep 25, 2025
7bf64c8
Use format macro to dump proof expiry
Doy-lee Sep 25, 2025
e3593e6
Add community message parsing to handle pro signature from content or…
Doy-lee Sep 25, 2025
d9ca60b
Add encode/decode for community messages
Doy-lee Sep 25, 2025
8ba9221
Rename encrypt/decrypt_for to encode/decode_for for consistency
Doy-lee Sep 25, 2025
60ffe90
Rename encrypt->encode and implement 1o1 padding/unpadding
Doy-lee Sep 25, 2025
5ef7481
Simplify encrypt_for_destination because we do not need to support le…
Doy-lee Sep 27, 2025
fc78eb7
Correctly prefix pro structures in session protocol
Doy-lee Sep 27, 2025
b03aa18
Encode/decode protocol messages now take the pro key and sign the mes…
Doy-lee Sep 27, 2025
de12113
Merge community encoding to single function, support inbox messages
Doy-lee Sep 27, 2025
0f108c0
Allow configurable session pro backend URL in unit tests
Doy-lee Sep 29, 2025
02a0fe9
Formatting
Doy-lee Sep 29, 2025
99210b2
Implement C wrappers for encode_for_community/inbox
Doy-lee Sep 29, 2025
a87a255
Add missing stdint include for uint64_t in blinding.h
Doy-lee Sep 29, 2025
e03a1d0
Clarify padding requirement in interface
Doy-lee Sep 29, 2025
5d3ac79
Fix outdated reference to pro data instead of pro config
Doy-lee Sep 29, 2025
a02c38c
Update outdated doc comments for session encrypt
Doy-lee Sep 30, 2025
aaad6dd
Correctly handle envelope source from ios/android and parse timestamps
Doy-lee Oct 2, 2025
2d82cd7
Verify the timestamp is decoded in unit tests
Doy-lee Oct 2, 2025
c4ec3d1
Update payment provider metadata table with new required fields
Doy-lee Oct 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@
[submodule "external/oxen-logging"]
path = external/oxen-logging
url = https://github.com/oxen-io/oxen-logging.git
[submodule "external/simdutf"]
path = external/simdutf
url = https://github.com/simdutf/simdutf.git
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# Session utility library

## Build

```
# Configure the build
#
# Options
# Enable APIs for creating onion-requests with:
#
# -D ENABLE_ONIONERQ
#
# Enable testing of a Session Pro Backend by defining on the configure line:
#
# -D TEST_PRO_BACKEND_WITH_DEV_SERVER=1
#
# These tests require the Session Pro Backend running in development mode (SESH_PRO_BACKEND_DEV=1)
# to be running and tests the request and response flow of registering, updating and revoking
# Session Pro from the development backend. You must also have a libcurl available such that
# `find_package(CURL)` succeeds (e.g. a system installed libcurl) for this to compile
# successfully.
#
# By default, it contacts http://127.0.0.1:5000 but this URL can be changed using the CLI arg
# --pro-backend-dev-server-url="<url>" when invoking the test suite.
#
cmake -G Ninja -S . -B Build

# Build
cmake --build Build --parallel --verbose
```

## Docs

C Library: https://api.oxen.io/libsession-util-c/#/
Expand Down
11 changes: 11 additions & 0 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,14 @@ libsession_static_bundle(libzstd_static)
set(JSON_BuildTests OFF CACHE INTERNAL "")
set(JSON_Install ON CACHE INTERNAL "") # Required to export targets that we use
libsession_system_or_submodule(NLOHMANN nlohmann_json nlohmann_json>=3.7.0 nlohmann-json)

set(JSON_BuildTests OFF CACHE INTERNAL "")
set(JSON_Install ON CACHE INTERNAL "") # Required to export targets that we use

function(simdutf_subdir)
set(SIMDUTF_TESTS OFF CACHE BOOL "")
set(SIMDUTF_TOOLS OFF CACHE BOOL "")
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(simdutf)
endfunction()
simdutf_subdir()
1 change: 1 addition & 0 deletions external/simdutf
Submodule simdutf added at 7b3f5a
11 changes: 6 additions & 5 deletions include/session/blinding.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ extern "C" {
#endif

#include <stddef.h>
#include <stdint.h>

#include "export.h"
#include "platform.h"
Expand All @@ -15,7 +16,7 @@ extern "C" {
///
/// Inputs:
/// - `ed25519_seckey` -- [in] the Ed25519 private key of the sender (64 bytes).
/// - `server_pk` -- [in] the public key of the open group server to generate the
/// - `server_pk` -- [in] the public key of the community server to generate the
/// blinded id for (32 bytes).
/// - `blinded_pk_out` -- [out] pointer to a buffer of at least 32 bytes where the blinded_pk will
/// be written if generation was successful.
Expand All @@ -36,7 +37,7 @@ LIBSESSION_EXPORT bool session_blind15_key_pair(
///
/// Inputs:
/// - `ed25519_seckey` -- [in] the Ed25519 private key of the sender (64 bytes).
/// - `server_pk` -- [in] the public key of the open group server to generate the
/// - `server_pk` -- [in] the public key of the community server to generate the
/// blinded id for (32 bytes).
/// - `blinded_pk_out` -- [out] pointer to a buffer of at least 32 bytes where the blinded_pk will
/// be written if generation was successful.
Expand Down Expand Up @@ -75,7 +76,7 @@ LIBSESSION_EXPORT bool session_blind_version_key_pair(
///
/// Inputs:
/// - `ed25519_seckey` -- [in] the Ed25519 private key of the sender (64 bytes).
/// - `server_pk` -- [in] the public key of the open group server to generate the
/// - `server_pk` -- [in] the public key of the community server to generate the
/// blinded id for (32 bytes).
/// - `msg` -- [in] Pointer to a data buffer containing the message to generate a signature for.
/// - `msg_len` -- [in] Length of `msg`
Expand All @@ -97,7 +98,7 @@ LIBSESSION_EXPORT bool session_blind15_sign(
///
/// Inputs:
/// - `ed25519_seckey` -- [in] the Ed25519 private key of the sender (64 bytes).
/// - `server_pk` -- [in] the public key of the open group server to generate the
/// - `server_pk` -- [in] the public key of the community server to generate the
/// blinded id for (32 bytes).
/// - `msg` -- [in] Pointer to a data buffer containing the message to generate a signature for.
/// - `msg_len` -- [in] Length of `msg`
Expand Down Expand Up @@ -145,7 +146,7 @@ LIBSESSION_EXPORT bool session_blind_version_sign(
/// Inputs:
/// - `session_id` -- [in] the session_id to compare (66 bytes with a 05 prefix).
/// - `blinded_id` -- [in] the blinded_id to compare, can be either 15 or 25 blinded (66 bytes).
/// - `server_pk` -- [in] the public key of the open group server to the blinded id came from (64
/// - `server_pk` -- [in] the public key of the community server to the blinded id came from (64
/// bytes).
///
/// Outputs:
Expand Down
6 changes: 2 additions & 4 deletions include/session/config/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <list>
#include <memory>
#include <session/config.hpp>
#include <session/types.hpp>
#include <session/util.hpp>
#include <span>
#include <type_traits>
Expand All @@ -29,9 +30,6 @@ class bt_dict_consumer;

namespace session::config {

template <typename T, typename... U>
static constexpr bool is_one_of = (std::is_same_v<T, U> || ...);

/// True for a dict_value direct subtype, but not scalar sub-subtypes.
template <typename T>
static constexpr bool is_dict_subtype = is_one_of<T, config::scalar, config::set, config::dict>;
Expand Down Expand Up @@ -944,7 +942,7 @@ class ConfigBase : public ConfigSig {
/// API: base/ConfigBase::load_key
///
/// Called to load an ed25519 key for encryption; this is meant for use by single-ownership
/// config types, like UserProfile, but not shared config types (closed groups).
/// config types, like UserProfile, but not shared config types (groups).
///
/// Takes a binary string which is either the 32-byte seed, or 64-byte libsodium secret (which
/// is just the seed and pubkey concatenated together), and then calls `key(...)` with the seed.
Expand Down
4 changes: 2 additions & 2 deletions include/session/config/convo_info_volatile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ class val_loader;
/// included, but will be 0 if no messages are read.
/// u - will be present and set to 1 if this conversation is specifically marked unread.
///
/// g - group conversations (aka new, non-legacy closed groups). The key is the group identifier
/// g - group conversations (aka new, non-legacy groups). The key is the group identifier
/// (beginning with 03). Values are dicts with keys:
/// r - the unix timestamp (in integer milliseconds) of the last-read message. Always
/// included, but will be 0 if no messages are read.
/// u - will be present and set to 1 if this conversation is specifically marked unread.
///
/// C - legacy group conversations (aka closed groups). The key is the group identifier (which
/// C - legacy group conversations (aka groups). The key is the group identifier (which
/// looks indistinguishable from a Session ID, but isn't really a proper Session ID). Values
/// are dicts with keys:
/// r - the unix timestamp (integer milliseconds) of the last-read message. Always included,
Expand Down
6 changes: 3 additions & 3 deletions include/session/config/groups/info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class Info : public ConfigBase {
/// API: groups/Info::set_delete_before
///
/// Sets a "delete before" unix timestamp: this instructs clients to delete all messages from
/// the closed group history with a timestamp earlier than this value. Returns nullopt if no
/// the group history with a timestamp earlier than this value. Returns nullopt if no
/// delete-before timestamp is set.
///
/// The given value is checked for sanity (e.g. if you pass milliseconds it will be
Expand All @@ -250,7 +250,7 @@ class Info : public ConfigBase {
/// API: groups/Info::get_delete_before
///
/// Returns the delete-before unix timestamp (seconds) for the group; clients should delete all
/// messages from the closed group with timestamps earlier than this value, if set.
/// messages from the group with timestamps earlier than this value, if set.
///
/// Returns std::nullopt if no delete-before timestamp is set.
///
Expand Down Expand Up @@ -279,7 +279,7 @@ class Info : public ConfigBase {
/// API: groups/Info::get_delete_attach_before
///
/// Returns the delete-attachments-before unix timestamp (seconds) for the group; clients should
/// delete all messages from the closed group with timestamps earlier than this value, if set.
/// delete all messages from the group with timestamps earlier than this value, if set.
///
/// Returns std::nullopt if no delete-attachments-before timestamp is set.
///
Expand Down
13 changes: 13 additions & 0 deletions include/session/config/groups/keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
extern "C" {
#endif

#include "../../types.h"
#include "../base.h"
#include "../util.h"

Expand Down Expand Up @@ -132,6 +133,18 @@ LIBSESSION_EXPORT size_t groups_keys_size(const config_group_keys* conf);
/// - `const unsigned char*` -- pointer to the 32-byte key, or nullptr if there
LIBSESSION_EXPORT const unsigned char* groups_keys_get_key(const config_group_keys* conf, size_t N);

/// API: groups/groups_keys_group_enc_key
///
/// Accesses the current encryption key: that is, the most current group decryption key. Returns the
/// 32 byte private key, or, an empty span if there are no encryption keys at all.
///
/// Inputs:
/// - `conf` -- the groups config object
///
/// Outputs:
/// - `true` if we have admin keys, `false` otherwise.
LIBSESSION_EXPORT const span_u8 groups_keys_group_enc_key(const config_group_keys* conf);

/// API: groups/groups_keys_is_admin
///
/// Returns true if this object has the group private keys, i.e. the user is an all-powerful
Expand Down
53 changes: 10 additions & 43 deletions include/session/config/groups/keys.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,46 +664,12 @@ class Keys : public ConfigSig {

/// API: groups/Keys::encrypt_message
///
/// Compresses, signs, and encrypts group message content.
///
/// This method is passed a binary value containing a group message (typically a serialized
/// protobuf, but this method doesn't care about the specific data). That data will be, in
/// order:
/// - compressed (but only if this actually reduces the data size)
/// - signed by the user's underlying session Ed25519 pubkey
/// - tagged with the user's underlying session Ed25519 pubkey (from which the session id can be
/// computed).
/// - all of the above encoded into a bt-encoded dict
/// - suffix-padded with null bytes so that the final output value will be a multiple of 256
/// bytes
/// - encrypted with the most-current group encryption key
///
/// Since compression and padding is applied as part of this method, it is not required that the
/// given message include its own padding (and in fact, such padding will typically be
/// compressed down to nothing (if non-random)).
///
/// This final encrypted value is then returned to be pushed to the swarm as-is (i.e. not
/// further wrapped). For users downloading the message, all of the above is processed in
/// reverse by passing the returned message into `decrypt_message()`.
///
/// The current implementation uses XChaCha20-Poly1305 for encryption and zstd for compression;
/// the bt-encoded value is a dict consisting of keys:
/// - "": the version of this encoding, currently set to 1. This *MUST* be bumped if this is
/// changed in such a way that older clients will not be able to properly decrypt such a
/// message.
/// - "a": the *Ed25519* pubkey (32 bytes) of the author of the message. (This will be
/// converted to a x25519 pubkey to extract the sender's session id when decrypting).
/// - "s": signature by "a" of whichever of "d" or "z" are included in the data.
/// Exacly one of:
/// - "d": the uncompressed data (which must be non-empty if present)
/// - "z": the zstd-compressed data (which must be non-empty if present)
///
/// When compression is enabled (by omitting the `compress` argument or specifying it as true)
/// then ZSTD compression will be *attempted* on the plaintext message and will be used if the
/// compressed data is smaller than the uncompressed data. If disabled, or if compression does
/// not reduce the size, then the message will not be compressed.
///
/// This method will throw on failure, which can happen in two cases:
/// Compresses, signs, and encrypts group message content with the user's underlying session
/// Ed25519 pubkey and the most-current group encryption key.
///
/// See: crypto/encrypt_for_group
///
/// This method will throw on failure:
/// - if there no encryption keys are available at all (which should not occur in normal use).
/// - if given a plaintext buffer larger than 1MB (even if the compressed version would be much
/// smaller). It is recommended that clients impose their own limits much smaller than this
Expand All @@ -728,12 +694,13 @@ class Keys : public ConfigSig {

/// API: groups/Keys::decrypt_message
///
/// Decrypts group message content that was presumably encrypted with `encrypt_message`,
/// Decrypts group message content that encrypted with `encrypt_message`.
///
/// See: crypto/decrypt_group_message
/// verifies the sender signature, decompresses the message (if necessary) and then returns the
/// author pubkey and the plaintext data.
///
/// To prevent against memory exhaustion attacks, this method will fail if the value is
/// a compressed value that would decompress to a value larger than 1MB.
/// See: crypto/decrypt_group_message
///
/// Inputs:
/// - `ciphertext` -- an encrypted, encoded, signed, (possibly) compressed message as produced
Expand Down
34 changes: 34 additions & 0 deletions include/session/config/namespaces.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

typedef enum NAMESPACE {
// Messages sent to an updated group which should be able to be retrieved by revoked
// members are stored in this namespace
NAMESPACE_REVOKED_RETRIEVABLE_GROUP_MESSAGES = -11,

// Messages sent to one-to-one conversations are stored in this namespace
NAMESPACE_DEFAULT = 0,
NAMESPACE_USER_PROFILE = 2,
NAMESPACE_CONTACTS = 3,
NAMESPACE_CONVO_INFO_VOLATILE = 4,
NAMESPACE_USER_GROUPS = 5,

// Messages sent to a group:
NAMESPACE_GROUP_MESSAGES = 11,
// Groups config namespaces (i.e. for shared config of the group itself, not one user's group
// settings)
NAMESPACE_GROUP_KEYS = 12,
NAMESPACE_GROUP_INFO = 13,
NAMESPACE_GROUP_MEMBERS = 14,

// The local config should never be pushed but this gives us a nice identifier for each config
// type
NAMESPACE_LOCAL = 9999,
} NAMESPACE;

#ifdef __cplusplus
} // extern "C"
#endif
26 changes: 16 additions & 10 deletions include/session/config/namespaces.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,31 @@

#include <cstdint>

#include "namespaces.h"

namespace session::config {

enum class Namespace : std::int16_t {
UserProfile = 2,
Contacts = 3,
ConvoInfoVolatile = 4,
UserGroups = 5,
RevokedRetrievableGroupMessages = NAMESPACE_REVOKED_RETRIEVABLE_GROUP_MESSAGES,

// Messages sent to one-to-one conversations are stored in this namespace
Default = NAMESPACE_DEFAULT,
UserProfile = NAMESPACE_USER_PROFILE,
Contacts = NAMESPACE_CONTACTS,
ConvoInfoVolatile = NAMESPACE_CONVO_INFO_VOLATILE,
UserGroups = NAMESPACE_USER_GROUPS,

// Messages sent to a closed group:
GroupMessages = 11,
// Messages sent to a group:
GroupMessages = NAMESPACE_GROUP_MESSAGES,
// Groups config namespaces (i.e. for shared config of the group itself, not one user's group
// settings)
GroupKeys = 12,
GroupInfo = 13,
GroupMembers = 14,
GroupKeys = NAMESPACE_GROUP_KEYS,
GroupInfo = NAMESPACE_GROUP_INFO,
GroupMembers = NAMESPACE_GROUP_MEMBERS,

// The local config should never be pushed but this gives us a nice identifier for each config
// type
Local = 9999,
Local = NAMESPACE_LOCAL,
};

} // namespace session::config
37 changes: 37 additions & 0 deletions include/session/config/pro.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

#include "../export.h"
#include "session/session_protocol.h"

typedef struct pro_config {
bytes64 rotating_privkey;
session_protocol_pro_proof proof;
} pro_pro_config;

/// Verify the proof was signed by the `verify_pubkey` and that the `rotating_privkey` in the `pro`
/// config rederives to the `rotating_pubkey` embedded in the proof.
///
/// Inputs:
/// - `proof` -- Proof to verify
/// - `verify_pubkey` -- Array of bytes containing the public key to (typically the Session Pro
/// Backend public key) verify the proof against.
/// - `verify_pubkey_len` -- Length of the `verify_pubkey` this must be 32 bytes, but is
/// parameterised to detect errors about incorrectly sized arrays by the caller.
///
/// Outputs:
/// - `bytes32` -- The 32 byte hash calculated from the proof
LIBSESSION_EXPORT bool pro_config_verify_signature(
pro_pro_config const* pro, uint8_t const* verify_pubkey, size_t verify_pubkey_len)
NON_NULL_ARG(1, 2);

#ifdef __cplusplus
} // extern "C"
#endif
Loading